VUEX中关于 mapActions, mapMutations使用

    技术2022-07-13  91

    换一种方式说就是ES6形式vuex 大项目中为了简洁代码直接可以这样调用

    第一步导入

    import {mapActions} from ‘vuex’

    第二部在methods 中引用 …mapActions([‘setKeyWords’,‘setLogoUrl’,‘setUserInfo’])

    这样就可以把 this.$store.dispatch(‘incrementBy’, amount)`

    简洁为 this.‘incrementBy’(‘amount’)

    Processed: 0.027, SQL: 9