问题描述
我正在尝试在nuxtjs中完成我的状态的延迟加载。 我正在使用vuex-module-decorators软件包。
我将状态保留在“ store /”文件夹之外,因此nuxt不会自动注册它们。 加载页面后,我会注册状态并立即加载它:
created(){
this.$store.registerModule('myModule',MyModule);
this.myState = getModule(MyModule,this.$store);
}
稍后在按钮上单击“我打电话”:
this.mystate.doStuff();
,但出现错误。
Uncaught (in promise) Error: ERR_ACTION_ACCESS_UNDEFINED: Are you trying to access this.someMutation() or this.someGetter inside an @Action?
That works only in dynamic modules.
If not dynamic use this.context.commit("mutationName",payload) and this.context.getters["getterName"]
Error: Could not perform action doStuff
...
Error: ERR_STORE_NOT_PROVIDED: To use getModule(),either the module
should be decorated with store in decorator,i.e. @Module({store: store}) or
store should be passed when calling getModule(),i.e. getModule(MyModule,this.$store)
我希望使用vuex-module-decorators的“动态”选项,但是我无法在Vue组件之外获得对存储对象的引用。
Vuex模块的外观如下:
@Module({
name: 'myModule',stateFactory: true,namespaced: true,})
export default class MyModule extends VuexModule {
@Action
doStuff(){
console.log('DoStuff');
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)