Vuejs2 Vuex-如何检查模块是否已注册
当尝试使用Vuejs2 Vuex-如何检查模块是否已注册,vuejs2,vuex,vuex-modules,Vuejs2,Vuex,Vuex Modules,当尝试使用this.$store.unregisterModule([ModulePath,ModuleName])注销模块时,有时我会收到此警告控制台[vuex]尝试注销未注册的模块“ModulePath\ModuleName” 我想知道是否有办法检查特定模块是否已注册?所以我可以这样做一个有条件的注销: if(module ModuleName is registered) { this.$store.unregisterModule([ModulePath, ModuleName])
this.$store.unregisterModule([ModulePath,ModuleName])
注销模块时,有时我会收到此警告控制台[vuex]尝试注销未注册的模块“ModulePath\ModuleName”
我想知道是否有办法检查特定模块是否已注册?所以我可以这样做一个有条件的注销:
if(module ModuleName is registered) {
this.$store.unregisterModule([ModulePath, ModuleName])
}
您可以通过调用
store.hasModule
来完成。
从Vuex文档:
注意,您可以通过store.hasModule(moduleName)方法检查模块是否已注册到存储
请参见您可以通过调用
store.hasModule
来完成此操作。
从Vuex文档:
注意,您可以通过store.hasModule(moduleName)方法检查模块是否已注册到存储
看