const state = {
account:"",
const getters = {
account(state){
return state.account
},
const mutations = {
increment(state,ret){//处理数据(数据是重点)变化 状态
state.account= ret.userPayInfo
},
};
const actions = {
increment:({commit})=>{//处理你要干啥
Api.member.account.get.account().then(({ret,msg,code}) =>
{
commit('increment',ret) //之前是数据 state.account=ret.userPayinfo 后面直接挂载在 mutations上去
}).catch(err =>
{
});
},
export default{state,actions,getters,mutations};
import {mapGetters,mapActions} from 'vuex';
export default {
data(){
return {
aa:this.$store.count
}
},
computed:mapGetters([
'count',
'Promise'
]),
methods:mapActions([
'increment',
'ad',
'aaa',
'bbb'
]),
}
...mapState({
info: state => state.user.info,
}),