vuex跨模块的mapGetter和mapMutation

映射
...mapGetters("模块名",['字段名'])
...mapState("模块名",['字段名'])
直接操作
this.$store.getters["模块名/字段名"]
this.$store.commit["模块名/方法名"]
映射别名
...mapState('some/xxx/module', {
    a1: state => state.a,
    b1: state => state.b
})

...mapMutaions('some/xxx/module', ['foo', 'bar'])

...mapActions('some/xxx/module', [
    'foo', // -> this.foo()
    'bar' // -> this.bar()
])

 

posted @ 2021-12-18 11:08  全玉  阅读(289)  评论(0编辑  收藏  举报