Vue3 的watch 監(jiān)視屬性
1. 監(jiān)聽(tīng)單個(gè) watch(變量,(新值,老值)=>{})
2. 監(jiān)聽(tīng)多個(gè) watch([變量1,變量2],(新值,老值)=>{})
3. 監(jiān)聽(tīng)對(duì)象 watch(()=>對(duì)象,(新值)=>{})
4. 監(jiān)聽(tīng)對(duì)象屬性 watch(()=>對(duì)象.屬性,(新值,老值)=>{})
5. 監(jiān)聽(tīng)對(duì)象多個(gè)屬性 watch([()=>對(duì)象.屬性1,()=>對(duì)象.屬性2],(新值,老值)=>{})
6. 監(jiān)聽(tīng)對(duì)象屬性,且該屬性值是引用類型 watch(()=>對(duì)象.屬性,(新值,老值)=>{},{ deep:true })
大總結(jié): watch(監(jiān)聽(tīng)目標(biāo),執(zhí)行函數(shù),配置) // 配置主要包含 { deep:true/false,immediate:true/false }
鏈接:https://www.dianjilingqu.com/608595.html
標(biāo)簽: