在使用store时,出现'getters' of undefine,页面空白
在网上找了vuex3.0和4.0的区别的文章,发现
使用对比
- state
-
// 3.0 { computed:{ name(){ return this.$store.state.name }, ...mapState('moduleName', [...]) } } // 4.x { setup(){ // 单一值引入 const name = computed(() => store.state.name ) // 引入整个state const name = computed( () => store.sate ) } } 按照4.x的修改ok了
- 3.0
- 4.x
详细请去这位大神博客了解:https://cloud.tencent.com/developer/article/1620623