console
const store = new Vuex.Store({
getters: {
someOtherGetter: state => 'ROOT'
},
actions: {
someOtherAction() {
console.log('ROOT_ACTION');
}
},
modules: {
moduleA: {
namespaced: true,
getters: {
someGetter(state,getters,rootState,rootGetters) {
return getters.someOtherGetter; // INSIDE
// return rootGetters.someOtherGetter; // ROOT
},
someOtherGetter: state => "INSIDE"
},
actions: {
someAction({ dispatch, getters, rootGetters }) {
console.log(getters.someOtherGetter);//INSIDE
console.log(rootGetters.someOtherGetter);//ROOT
dispatch('someOtherAction');//INSIDE_ACTION
dispatch('someOtherAction', null, {root: true});//ROOT_ACTION
},
someOtherAction() {
console.log('INSIDE_ACTION');
}
}
}
}
});
console.log(store.getters['moduleA/someGetter']);
store.dispatch('moduleA/someAction');
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://unpkg.com/vuex"></script>