【发布时间】:2019-09-19 12:00:13
【问题描述】:
我正在动态注册 vuex 存储模块
store.registerModule('home.grid', GridStore)
然后在组件中:
export default {
name: 'GridComponent',
props: {
namespace: {
type: String,
required: true
},
computed: {
...mapState(this.namespace, ['filter']) // doesn't work
filter() { // more verbose but working
return this.$store.state[this.namespace].filter
}
}
...
但我得到了错误:
无法读取未定义的属性“命名空间”
有什么想法吗?
问题最初来自“gabaum10”https://forum.vuejs.org/t/vuex-dynamic-namespaces-in-mapstate-mapactions/28508
【问题讨论】:
-
gabaum10 似乎也在同一个线程中找到了答案。这不适合你吗?
标签: vuex