首先说一下传值
1 | const mutations = { |
1 | <button @click="$store.commit('add',2)">+</button> |
然后跟上篇一样在调用的时候写法太烦,类似的我们用mapMutations
1 | import {mapState,mapMutations} from'vuex' |
1 | <button @click="add(1)">+</button> |
Work hard for what you desire.
首先说一下传值
1 | const mutations = { |
1 | <button @click="$store.commit('add',2)">+</button> |
然后跟上篇一样在调用的时候写法太烦,类似的我们用mapMutations
1 | import {mapState,mapMutations} from'vuex' |
1 | <button @click="add(1)">+</button> |