vuex辅助函数mapActions、mapMutations传递自定义参数

mapActions传参

方式1
this.$store.dispatch('setShowLogin', true)

方式2
this.setShowLogin() 映射为 this.$store.dispatch('setShowLogin')
...mapActions([ 'setShowLogin', ]),


方式3
this.isLogin() 映射为 this.$store.dispatch('setShowLogin')
...mapActions({ isLogin:'setShowLogin', }),

或 this.isLogin(true)

mapMutations传参
方式1
this.$store.commit('SET_SHOW_LOGIN', true)

【vuex辅助函数mapActions、mapMutations传递自定义参数】其他传参方法基本与mapActions相同
如有问题,请联系作者,及时纠正

    推荐阅读