在vuex中的mutations中定义的一个函数,在组件中调用//store.js在mutations中定义addCart:function (state,{goodIndex,foodIndex}) { state.goods[goodIndex].foods[foodIndex].count++; },//组件中调用methods:{ ...mapMutations(['addCart','removeCart','setCart']), addCartItem:function(){ this.setCart({goodIndex:this.goodIndex,foodIndex:this.foodIndex}); }} 我的问题是为什么在调用setCart函数的时候不用传入state参数,目测如果调用的时候不传state参数的话,addCart函数执行的时候就会自动将在store中的state传入进去,这样的原理是什么??这是自己半个月前写的代码,现在看怎么也不理解了。。
添加回答
举报
0/150
提交
取消