我正在使用带有模块的 Vuex 3.2.0。
在我的一个模块中,我需要从初始state: { ... }定义中访问 rootState。我该怎么做呢?
// my-module.js
export default {
namespaced: true,
state: {
// I can't actually use `rootState` here so how do I access it?
foo: rootState.appConfig.bar + 'baz';
},
mutations: { ... },
actions: { ... },
getters: { ... }
}
我不想使用没有任何实际状态值的 getter,因为我需要能够改变这个值。