Search code examples
javascriptvue.jsvue-componentvuexvuex-modules

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?


Solution

  • 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'));