简体   繁体   English

Vuex:从不同模块getter中的另一个模块访问状态

[英]Vuex: Accessing state from anther module inside different module getter

I'm trying to access state from another namespaced vuex modue inside getter in a different module, this is what I'm trying: 我正在尝试从另一个模块中的getter中的另一个命名空间的vuex模式访问状态,这是我正在尝试的:

//GETTERS
const getters = {

    authorizedAdminLinks: ({ rootState }) =>  _.filter(rootState.globals.adminLinks, link => link.seePrivilege >= rootState.globals.auth.privileges),
}

I'm getting the following error: 我收到以下错误:

[Vue warn]: Error in render: "TypeError: rootState is undefined"

When defined in a module, a getter receives rootState as a third argument : 在模块中定义时,getter会接收rootState作为第三个参数

const getters = {
    authorizedAdminLinks: (state, getters, rootState) =>  _.filter(rootState.globals.adminLinks, link => link.seePrivilege >= rootState.globals.auth.privileges),
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM