Accessing global elements

In the namespaced module getters, you can access the root state and root getters (which means any getter) like this:

someGetter: (state, getters, rootState, rootGetters) => { /* ... */ }

In the actions, you have access to rootGetters in the context and you can use the { root: true } option for the commit and dispatch calls:

myAction ({ dispatch, commit, getters, rootGetters }) {
getters.a // store.getters['maps/a']
rootGetters.a // store.getters['a']
commit('someMutation') // 'maps/someMutation'
commit('someMutation', null, { root: true }) // 'someMutation'
dispatch('someAction') // 'maps/someAction'
dispatch('someAction', null, { root: true }) // 'someAction'
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.8.247