vuex代码(部分):
const state = {
shopNameList: [],
test: [1, 2, 3]
}
const getters = {
shopNameList: (state) => state.shopNameList,
test: (state) => state.test
}
组件代码(部分):
computed: {
...mapGetters({ // 这样可以获取
shopNameList: 'shopNameList',
test: 'test'
})
},
computed: {
...mapState({ // 获取不到数据
shopNameList: 'shopNameList',
test: 'test'
})
},
mapState 返回的是一个数组