Vue.js 当使用基于类的方法时,如何将存储操作映射到组件?

Vue.js 当使用基于类的方法时,如何将存储操作映射到组件?,vue.js,vuex,vue-class-components,Vue.js,Vuex,Vue Class Components,这是我的vuejs组件,我正在使用基于类的appraoch <template> //template body here </template> <script> import Vue from "vue"; import moment from "moment"; import Component from "vue-class-component"; import { State, Action, Mutation, namespace } f

这是我的
vuejs
组件,我正在使用基于类的appraoch

<template>
    //template body here
</template>

<script>
import Vue from "vue";
import moment from "moment";
import Component from "vue-class-component";
import { State, Action, Mutation, namespace } from "vuex-class";

const homeModule = namespace("../store/modules/list");  //path is OK

export default class List extends Vue {
    @State(state => state.list.apps) items;     //working properly
    @homeModule.Action("fetchItems") fetchItems;    //not working

    mounted() {
        this.fetchItems();
    }

}
</script>
现在,我可以从商店获得商品清单。但无法将动作映射到组件。 它显示了在mapActions()中找不到的错误
[vuex]模块命名空间:../store/modules/list/

任何帮助都将不胜感激。
谢谢

如果您仍然有问题,您在排队时走错了路

const homeModule=namespace(“../store/modules/list”);
is应该是命名空间存储中的路径,而不是文件的路径,因此它应该类似于:

const homeModule=名称空间(“列表”);

如果您的模块注册在
列表
键下

为什么不使用常规方法
…mapState('storeModule',['fieldName'])
只是因为语法清晰
const state = {
    items: []
};

const mutations = {
    setItems(state, items) {
        state.items = items;
    }
};

const actions = {
    async fetchItems({ commit }) {
        const {data} = //Make a request for fetching the items
        commit('setItems', items);
    }
};

export default {
    namespaced: true,
    state,
    actions,
    mutations
};