gpt4 book ai didi

javascript - Vuex - rawModule 未定义,从单个模块移动到多个模块

转载 作者:行者123 更新时间:2023-11-30 14:37:28 32 4
gpt4 key购买 nike

documentation 之后将我的项目从 vuex 存储中的单个模块移动到多个.

它声明特定模块应该像这样访问:

store.state.a // -> `moduleA`'s state

这是访问模块状态的时候。它没有说明如何访问 getter 和突变以及特定模块的“commit”和“replaceState”等命令,因此我得出了自己的结论:

store.getters.a
store.mutations.a
store.a.commit()
store.a.replaceState()

1) 这些结论是否正确?

2) 使用这些我得到一个非常普遍的错误信息:

TypeError: rawModule is undefined

这是我的 store.js:

import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
modules: {
listingModule: listingModule,
openListingsOnDashModule: listingsOnDashModule,
closedListingsOnDashModule: listingsOnDashModule
}
})

const listingsOnDashModule = {...}
const listingModule = {...}
// their content hasn't changes since the single module approach.

最佳答案

这个错误:

TypeError: rawModule is undefined

是由于尝试将 undefined 注册为模块引起的,您可能在注册模块时不小心导入了 undefined

至于语法store.state.a是正确的。对于其余部分,.a 应该被省略,除非您明确定义了一个命名空间。

关于javascript - Vuex - rawModule 未定义,从单个模块移动到多个模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50198719/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com