본문 바로가기
✘✘✘ Vue/VueX

[vue] vuex: dispatch actions btw vuex modules? namespace?

by PrettyLog 2022. 7. 6.

Is there a way to dispatch actions between two namespaced vuex modules?

Search: vuex dispatch action from another module

You just need to specify that you're dispatching from the root context:

// from the gameboard.js vuex module
dispatch('notification/triggerSelfDismissingNotifcation', {...}, {root:true})

Now when the dispatch reaches the root it will have the correct namespace path to the notifications module (relative to the root instance).

This is assuming you're setting namespaced: true on your Vuex store module.

댓글