@aubrey
To get all registered Vuex modules, you can use the store
object's modules
property. This property contains all the registered module objects, where the module name is the key and the module object is the value.
Here is an example of how you can get all registered Vuex modules:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
// Import Vuex import Vue from 'vue' import Vuex from 'vuex' // Use Vuex Vue.use(Vuex) // Create a sample module const moduleA = { state: { count: 0 }, mutations: { increment: state => state.count++ } } // Create the store const store = new Vuex.Store({ modules: { moduleA } }) // Get all registered Vuex modules const registeredModules = store.modules console.log(registeredModules) |
In this example, the store.modules
property will output an object with moduleA
as the key and the module object as the value:
1 2 3 4 5 6 |
{ moduleA: { state: { count: 0 }, mutations: { increment: state => state.count++ } } } |
Note that this example is just to demonstrate how to get all registered modules. In reality, you may have multiple modules registered in your Vuex store.