我可能看不到明显的东西,但几个小时后我还是看不到。
问题是:当我将Vuex存储导入非组件文件(api服务)时,一个模块正确加载,而另一个模块仅按名称加载,但在其他方面为空。
// store.js
import * as collections from "./modules/collections";
import * as auth from "./modules/auth";
export default new Vuex.Store({
modules: {
auth,
collections
}
});
这两个模块几乎完全相同。两者都有
export const getters = {}
export const actions = {}
export const mutations = {}
export const state = {}
现在,当在其他一些非组件文件中
不要
包括商店,我的vue商店如下所示:
{"auth":{"authenticated":false,"authToken":"123","loginPending":false,"loginError":{}},"collections":{"collectionsPending":false,"collectionsError":null,"collections":[]}}
现在,当我导入商店以便在我的服务中使用它时,如下所示:
import store from '../store'
// NO OTHER MENTIONS OF STORE, ONLY IMPORTING
突然,只有我的身份验证模块是“空的”
{"auth":{},"collections":{"collectionsPending":false,"collectionsError":null,"collections":[]}}
它与模块加载有关。
添加加载顺序
console.log
声明:
我正在使用Vue Webpack样板