如题,
例如在vue2.x中的:
computed: {
...mapState('tabBar', {
isShow: (state) => state.isShow,
}),
//or: ...mapState('tabBar', ['isShow']),
},
在vue3.x中改怎么写?
尝试过以下写法:
setup(){
const isShow = computed(...mapState('tabBar', ['isShow']))
return { isShow }
}
setup(){
const isShow = computed(
...mapState('tabBar', {
isShow: (state) => state.isShow,
})
return { isShow }
}
以上写法均报错:TypeError: Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.
setup(){
computed(
mapState('tabBar', {
isShow: (state) => state.isShow,
})
)
}
setup(){
const isShow = computed(
mapState('tabBar', {
isShow: (state) => state.isShow,
})
)
}
以上写法报错:Property "isShow" was accessed during render but is not defined on instance.
at <App>
求解改怎么写?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…