export default new Vuex.Store({
state: {
username,
token,
accpng
},
mutations: {
setUserInfo(state, payload) {
const {
username,
token
} = payload
state.username = username
state.token = token
}
},
actions: {
asyncLogin(ctx, payload) {
axios('url/login', payload).then(res => {
ctx.commit('setUserInfo', res)
})
},
asyncLogina({commit}, payload) {
axios('url/login', payload).then(res => {
commit('setUserInfo', res)
})
}
},
getters: {},
modules: {}
})
export default{
mounted(){
let payload ={
key,password,username,token
}
this.$store.dispatch('asyncApi',payload)
}
}