If you want to access global/namespaced getter
from the module, Here is how you can,
getters: {
// `getters` is localized to this module's getters
// you can use rootGetters via 4th argument of getters
someGetter (state, getters, rootState, rootGetters) {
rootGetters.someOtherGetter //'someOtherGetter' global getter
rootGetters['bar/someOtherGetter'] //'bar/someOtherGetter' namespaced getter
},
...
},
Here is the way to access actions
, Also includes usage of action
and mutations
for reference.
actions: {
// dispatch and commit are also localized for this module
// they will accept `root` option for the root dispatch/commit
someAction ({ dispatch, commit, getters, rootGetters }) {
rootGetters.someGetter //'someGetter' global getter
rootGetters['bar/someGetter'] //'bar/someGetter' namespaced getter
dispatch('someOtherAction') //'someOtherAction' local action
dispatch('someOtherAction', null, { root: true }) //'someOtherAction' namespaced action
commit('someMutation') //'someMutation' local mutation
commit('someMutation', null, { root: true }) //'someMutation' namespaced mutation
},
...
}
}
rootGetters['moduleName/getterName']
. – Pease