这是我的模块:
const ModuleA={
namespaced:true,
state:{
categoryList:[
{name:'all', isActive:true},
{name:'negotiation', isActive:false},
]
},
getters:{
getCategory:(state)=>(index)=>{
return state.categoryList[index];
},
}
}
没有
namespaced:true
, 我可以调用getCategory
与 this.$store.getters.getCategory(this.index)
.如何调用
getCategory
与 namespaced:true
?我无法使用 mapGetters
因为我必须将参数传递给函数。
最佳答案
请参阅此 How to access Vuex module getters and mutations 的第二个答案
this.$store.getters['ModuleA/getCategory'](this.index)
关于vuejs2 - Vue.js 2/Vuex - 如何从具有命名空间属性 :true without mapGetters? 的模块调用 getter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47327388/