The mutations and getters in each module will receive the module's local state as their first argument, as follows:
const module1 = {
state: { number: 1 },
mutations: {
multiply (state) {
console.log(state.number)
}
},
getters: {
getNumber (state) {
console.log(state.number)
}
}
}
In this code, the state in the mutation and getter methods is the local module state, so you will get 1 for console.log(state.number), while in each module's actions, you will get the context as the first argument, which you can use to access the local state and root state as context.state and context.rootState, as follows:
const module1 = {
actions: {
doSum ({ state, commit, rootState }) {
//...
}
}
}
The root state is also available in each module's getters as the third argument, as follows:
const module1 = {
getters: {
getSum (state, getters, rootState) {
//...
}
}
}
The local state from the...