我是VueJS和Vuex的新手,所以我遇到了动态导入组件的问题 .
问题是,当我尝试访问此 . $ store时,将返回undefined .
这是我的文件结构: components - books.vue - modals -- bookOne.vue -- bookTwo.vue ... -- bookTen.vue
在books.vue我正在使用标签,我从modal文件夹加载组件 . 模态工作,组件被加载,但我无法使用此 . $ store进入模态 .
books.vue
<modal name="example">
<div class="basic-modal">
<h1 class="title">Modal Title</h1>
<component :is="this.modalComponent"></component>
<button class="button" type="button" @click="close">Close Modal</button>
</div>
</modal>
情态动词/ bookOne.vue
created () {
console.log('deb', this.$store)
// this.$store returns undefined
},
computed: {
testing() {
console.log('testing', this.$store)
// this.$store is undefined
}
},
我正在使用此模块作为模态:https://github.com/ktsn/vuex-modal
那么,可能是什么问题呢?也许是应用程序的实时循环,因为在初始化webpack之后动态导入模态或?
谢谢!