[vuex] 未知操作类型:getPackagingList

[vuex]unknown action type: getPackagingList

我正在使用带命名空间的 vuex,我为 vuex 创建了一个商店,当我调用操作时出现错误 [vuex] unknown action type: getPackagingList ,我检查了所有内容的拼写错误,但没有结果: 商店(index.js):

import Vue from 'vue'
import Vuex from 'vuex'
import state from './state';
import * as getters from './getters';
import * as mutations from './mutations';
import * as actions from './actions';
import packaging from './modules/item/packaging'
Vue.use(Vuex);
export default new Vuex.Store({
    namespaced: true,
    state,
    getters,
    actions,
    mutations,
    modules: {  
            packaging,
    }
})

index.js(打包):

import state from './state';
import * as getters from './getters';
import * as mutations from './mutations';
import * as actions from './actions';
export default {
    namespaced: true,
    state,
    getters,
    actions,
    mutations
};

actions.js:

import axios from 'axios'
import Vue from 'vue'
export const getPackagingList = ({ commit }) => {
        axios.get("product/packaging/index", {
          headers: {
            "Content-Type": "application/json",
            //  withCredentials: true //sent with cookie
            Authorization: "Bearer " + Vue.$cookies.get("jwt"),
          },
        })
        .then(res => {
            commit("SET_PACKAGING", res.data);
        })
  };

mutations.js

export const SET_PACKAGING = (state, packagingList) => {
    state.packagingList= packagingList;
  };

state.js

export default {
    packagingList:[],
    packagingId : null,
}

调用 mycomponent.vue 上的操作:

mounted() {
    this.getPackagingList();
}
methods: {
    ...mapActions(['getPackagingList']),
}

试试这个

mounted() {
    this.getPackagingList();
}
methods: {
    ...mapActions('packaging', ['getPackagingList']),
}