这是我的模块:
const ModuleA={
namespaced:true,
state:{
categoryList:[
{name:'all', isActive:true},
{name:'negotiation', isActive:false},
]
},
getters:{
getCategory:(state)=>(index)=>{
return state.categoryList[index];
},
}
}
Run Code Online (Sandbox Code Playgroud)
如果没有namespaced:true,我可以打电话getCategory用this.$store.getters.getCategory(this.index)。
如何调用getCategory与namespaced:true?我无法使用,mapGetters因为我必须将参数传递给函数。
请参阅此如何访问 Vuex 模块 getter 和突变的第二个答案
this.$store.getters['ModuleA/getCategory'](this.index)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2684 次 |
| 最近记录: |