当前位置: 首页 > Web前端 > vue.js

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

时间:2023-03-31 22:37:09 vue.js

mapActions参数传递方法一this.$store.dispatch('setShowLogin',true)方法二将this.setShowLogin()映射到this.$store.dispatch('setShowLogin')...mapActions(['setShowLogin',]),Login方法3将this.isLogin()映射到this.$store.dispatch('setShowLogin')...mapActions({isLogin:'setShowLogin',}),login或this.isLogin(true)mapMutations参数传递方法1this.$store。commit('SET_SHOW_LOGIN',true)其他参数传递方式与mapActions基本一致如有问题请联系作者及时改正

猜你喜欢