[英]Map a namespaced getter (maintaining reactivity) in Vuex?
I know you can use a standard getter from your Vuex store by importing mapGetters...我知道您可以通过导入 mapGetters 来使用 Vuex 商店中的标准 getter ...
import {mapGetters} from 'vuex';
Then adding a computed property as follows:然后添加一个计算属性,如下所示:
computed: {
...mapGetters({
myGetter: 'my-getter'
})
}
I have split my Vuex store into modules in order to use namespaced actions/mutations.我已将我的 Vuex 存储拆分为模块,以便使用命名空间的操作/突变。
I want to use 'mapGetters' in order to access a getter from a specific module.我想使用“mapGetters”来访问来自特定模块的吸气剂。
TL;DR - What would be the necessary changes in syntax for mapping a modular namespaced getter in Vuex from the above snippet? TL;DR - 从上面的代码片段中映射 Vuex 中的模块化命名空间 getter 的语法有哪些必要的变化?
This is the syntax to be used:这是要使用的语法:
computed: {
...mapGetters('moduleOne', ['getUsers'']),
...mapGetters('moduleTwo', ['getProducts'])
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.