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相同
如有问题,请联系作者,及时纠正
推荐阅读
- 一起来学习C语言的字符串转换函数
- C语言字符函数中的isalnum()和iscntrl()你都知道吗
- C语言浮点函数中的modf和fmod详解
- C语言中的时间函数clock()和time()你都了解吗
- 概率论/统计学|随机变量 的 分布函数 与 概率密度函数 的区别
- VueX--VUE核心插件
- vue组件中为何data必须是一个函数()
- iOS-Swift-map|iOS-Swift-map filter reduce、函数式编程
- vuex|vuex 基础结构
- VueX(Vuex|VueX(Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式)