state.count += payload;
}
},
actions:{
change(context,palyload){
context.commit('change',palyload);// 异步触发 mutaiton
}
},
getters:{
getCount(){
return state.count;
}
}
})
{{$store.state.count}}
<button @click="commitChange">更改count</button>
<button @click="dispatchChange">更改count</button>...
methods:{
commitChange(){
this.$store.commit('change',1);
},
dispatchChange(){
this.$sotre.dispatch('change',10);
}
}










