vuex中subscribe的使用
会在每个 mutation 完成后调用,接收 mutation 和经过 mutation 后的状态作为参数
App.vue
this.$store.commit('add')
store.js
const store = new Vuex.Store({
state:{
name:'xxx',
age:20
},
mutations:{
add(state){
console.log(state.age);
原创
2021-05-21 16:53:31 ·
1609 阅读 ·
0 评论