首先在组件中引入vuex的mapMutations方法:
import { mapMutations } from 'vuex'
然后在methods中这样写:
methods:{
...mapMutations( [ 'add','reduce' ] )
}
在组件中调用的时候这样写:
<button @click='add'>加</button>
<button @click='reduce'>减</button>
首先在组件中引入vuex的mapMutations方法:
import { mapMutations } from 'vuex'
然后在methods中这样写:
methods:{
...mapMutations( [ 'add','reduce' ] )
}
在组件中调用的时候这样写:
<button @click='add'>加</button>
<button @click='reduce'>减</button>