【发布时间】:2021-06-27 02:32:10
【问题描述】:
我的 NuxtJs 商店有问题,它总是返回 undefined 我发现了很多类似的问题,但没有一个能解决问题。这是我的代码:
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
state(){
return{
count: 500
}
},
getters: {
getCount: (state) => {
state.count
}
},
})
然后我试着用这种方式得到它
this.$store.getters.getCount
也试过了
computed: {
...mapGetters(['getCount'])
},
created(){
console.log("count: "+this['getCount'])
}
【问题讨论】: