Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all registered Vuex modules

Is there any way to iterate over all Vuex modules? I registered my namespaced modules like this:

$store.registerModule('module-xyz', module);

Now is there any way to get the list of all of them?

like image 216
iSun Avatar asked Sep 03 '25 17:09

iSun


1 Answers

It's undocumented, but you can get all modules through the _modules property:

console.log(this.$store._modules.root._children);

You can also check for the existence of a module with hasModule:

console.log(this.$store.hasModule('module-xyz'));
like image 153
Dan Avatar answered Sep 05 '25 09:09

Dan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!