How to Vuex state with a getter within a module from another module How to Vuex state with a getter within a module from another module vue.js vue.js

How to Vuex state with a getter within a module from another module


The relevant documentation is Accessing Global Assets in Namespaced Modules where it says:

If you want to use global state and getters, rootState and rootGetters are passed as the 3rd and 4th arguments to getter functions, and also exposed as properties on the context object passed to action functions.

So if you want to access the customerId getter of the modA module inside the mycustomer getter in the modB module, it should be:

mycustomer(state, getters, rootState, rootGetters) {  return rootGetters['modA/customerId']}