如何获取所有已注册的 Vuex 模块
How to get all registered Vuex modules
有什么方法可以遍历所有的 Vuex 模块吗?我这样注册了命名空间模块:
$store.registerModule('module-xyz', module);
现在有什么办法可以得到所有的列表吗?
它没有记录,但你可以通过 _modules
属性:
获取所有模块
console.log(this.$store._modules.root._children);
您还可以使用 hasModule
:
检查模块是否存在
console.log(this.$store.hasModule('module-xyz'));
有什么方法可以遍历所有的 Vuex 模块吗?我这样注册了命名空间模块:
$store.registerModule('module-xyz', module);
现在有什么办法可以得到所有的列表吗?
它没有记录,但你可以通过 _modules
属性:
console.log(this.$store._modules.root._children);
您还可以使用 hasModule
:
console.log(this.$store.hasModule('module-xyz'));