【发布时间】:2019-08-17 09:05:03
【问题描述】:
我正在尝试创建一个通用过滤器组件,从商店获取数据
现在,我像这样使用mapGetters
...mapGetters({
items: 'filters'
}),
但我希望能够将其概括为我正在映射的吸气剂
props: {
filterType: String
},
computed: {
...mapGetters({
items: this.filterType
}),
}
这给了我以下错误
Cannot read property 'nombre' of undefined
我知道我能做到:
computed: {
items: function () {
return this.$store.getters[this.filterType]
}
}
但我只是想检查是否有办法将 vue 实例的属性与 mapGetters 一起使用,或者您是否需要严格硬编码内部的 getters 名称
【问题讨论】: