vuex getter传参方法
getters: {getProductByid: (state) => (id) =>{return state.productList.find(item => item.id === id);}}this.$store.getters['yournamespace/getProductByid'](id);this.$store.getters.getProductByid
·
getters: {
getProductByid: (state) => (id) =>
{
return state.productList.find(item => item.id === id);
}
}
在使用了namespace的情况下调用:
this.$store.getters['yournamespace/getProductByid'](id);
在未使用namespace的情况下调用:
this.$store.getters.getProductByid(id);
更多推荐



所有评论(0)