const store = new Vuex.Store({
state: {
count: 0
},
mutations: {
increment (state) {
state.count++
}
},
actions: {
increment (context) {
context.commit('increment')
}
}
})
store 中的状态的唯一方法是提交 mutation
store.commit('increment')
---------------------------
Action 函数接受一个与 store 实例具有相同方法和属性的 context 对象,因此你可以调用 context.commit 提交一个 mutation [context 对象不是 store 实例本身了]
actions: {
increment ({ commit }) {
commit('increment')
}
}
----------------------------------------------------------
this.$store.dispatch() 与&
订阅专栏 解锁全文
1865




被折叠的 条评论
为什么被折叠?



