vue3项目(使用Composition API)(<script setup>)添加watch监听的时候报错,错误信息如下:
apply.vue:15 [Vue warn]: Invalid watch source: false A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.
修改前代码
watch(store.state.GlobalModule.isRefresh,(newValue)=>{
console.log('监听到isRefresh变化',newValue)
if(newValue){
requestOpenStatus()
}
})
修改后
watch(()=>store.state.GlobalModule.isRefresh,(newValue,olvalue)=>{
console.log('监听到isRefresh变化',newValue)
if(newValue){
requestOpenStatus()
}
})