【发布时间】:2019-11-17 04:53:44
【问题描述】:
我有根状态,其中包含来自 nuxt/auth.. 的身份验证数据。
在 store/modules/messages/ 里面我也有 state 和 getter 等。
在 getter 内部,我需要从根状态获取身份验证数据,但我不知道如何..
我尝试将 rootState 从模块添加到 index.js:
import state from './state'
import rootState from '../../state'
import * as actions from './actions'
import * as mutations from './mutations'
import * as getters from './getters'
export default {
namespaced: true,
state,
rootState,
getters,
mutations,
actions
}
export const avatar = (rootState) => rootState.auth.user.avatar
但这仍然返回模块状态..
【问题讨论】: