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);
Logo

Vue社区为您提供最前沿的新闻资讯和知识内容

更多推荐