这是我的vuejs
组件,我正在使用基于类的方法。
<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>
这是我的store/modules/list.js
。
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
};
现在,我可以从商店中获取商品列表。但无法将操作与组件映射。它显示错误[vuex] module namespace not found in mapActions(): ../store/modules/list/
任何帮助,将不胜感激。谢谢