vuex辅助函数mapActions、mapMutations传递自定义参数
文章目录
mapActions传参
方式1
this.$store.dispatch('setShowLogin', true)方式2
将this.setShowLogin()映射为this.$store.dispatch('setShowLogin')
...mapActions([
'setShowLogin',
]), <button @click="setShowLogin(true)">登录</button>方式3
将this.isLogin()映射为this.$store.dispatch('setShowLogin')
...mapActions({
isLogin:'setShowLogin',
}), <button @click="isLogin(true)">登录</button>
或
this.isLogin(true)
mapMutations传参
方式1
this.$store.commit('SET_SHOW_LOGIN', true)其他传参方法基本与mapActions相同
如有问题,请联系作者,及时纠正

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论