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()
    }
})
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐