【发布时间】:2019-03-07 20:42:00
【问题描述】:
在我的 ContactForm 组件中,我有 2 个计算的 mapGetters
computed: {
...mapGetters(["language"]),
...mapGetters("authentication", ["loading"]),
第一个在我的 stoe/getters.js 中定义
export const language = state => {
return state.language;
};
第二个是在我的 store/modules/authentication.js 中定义的
const authentication = {
namespaced: true,
getters: {
user: state => {
return state.user
},
loading: state => {
return state.loading
}
},
我正在尝试模拟我的 Vuex 商店,对于第一个“语言”来说很容易,
export const storeMock = Object.freeze({
state: {},
actions: {},
getters: {
language: () => { . // <= FINE
return "en";
},
authentication: { . // <= . WRONG
loading: () => {
return false;
}
}
}
})
但是我应该如何从“身份验证”模块模拟第二个“加载”?
【问题讨论】: