How do I call a getter from another getter in Vuex?
Pass getters
as the second argument to access local and non-namespaced getters. For namespaced modules, you should use rootGetters
(as the 4th argument, in order to access getters defined within another module):
export default foo = (state, getters, rootState, rootGetters) => {
return getters.yourGetter === rootGetters['moduleName/getterName']
}
In VueJS 2.0, you must pass both state
and getters
.
Getters are passed to other getters as the 2nd Argument:
export default foo = (state, getters) => {
return getters.yourGetter
}
Official documentation: https://vuex.vuejs.org/guide/getters.html#property-style-access