Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use mapGetters with modules and root's getters at the same time?

Tags:

People also ask

Can you have multiple Vuex stores?

Vuex gives you the flexibility to manage multiple store modules based on how you'd like to structure your project.

How do I access rootState in mutation Vuex?

You can make the check to your firstModule's myArray within the fetchData action. That's the best practice. But, if you really need to access the rootState variable in a mutation, you have to pass it in as a variable reference, like you are currently.


I know how to use mapGetters in a single situation, but not both.

Example, I have firstRootGetter inside store/index.js, so I will call ...mapGetters(['firstRootGetter']) in vue component.

If I have firstModuleGetter and secondModuleGetterinside store/modules/post.js, I will call ...mapGetters('post', ['firstModuleGetter', 'secondModuleGetter'])

My question is, how do I call them in single ...mapGetters. Is it possible?

Right now I have to write 2 lines to call them separately.