在vuex中的mutations中定義的一個函數(shù),在組件中調(diào)用//store.js在mutations中定義addCart:function (state,{goodIndex,foodIndex}) { state.goods[goodIndex].foods[foodIndex].count++; },//組件中調(diào)用methods:{ ...mapMutations(['addCart','removeCart','setCart']), addCartItem:function(){ this.setCart({goodIndex:this.goodIndex,foodIndex:this.foodIndex}); }} 我的問題是為什么在調(diào)用setCart函數(shù)的時候不用傳入state參數(shù),目測如果調(diào)用的時候不傳state參數(shù)的話,addCart函數(shù)執(zhí)行的時候就會自動將在store中的state傳入進去,這樣的原理是什么??這是自己半個月前寫的代碼,現(xiàn)在看怎么也不理解了。。
請問下面的函數(shù)寫法什么意思?
胡說叔叔
2018-11-14 14:15:19