import {
mapMutations,mapGetters
} from 'vuex'

mutations: {
incrementCount(state){
return state.count+=1;

},
// decrementCount(state,n){
// return state.count-=n;

// },

//可以传一个对象,数组
decrementCount(state,payload){
return state.count-=payload.mount;

}

 

button @click="incrementCount()">+</button>
<div>{{mount}}</div>
<button @click="decrementCount({mount:10})">=</button>

 

methods: {
// crease() {
// console.log(11)
// this.$store.commit("incrementCount",9)

// },
// decrease(m) {
// console.log(11)
// this.$store.commit("decrementCount",m)

// }
// }
methods: mapMutations(['decrementCount', 'incrementCount'])

posted on 2020-08-23 20:24  心意如水hucuie22  阅读(325)  评论(0编辑  收藏  举报