1、引用
import {ref, watch } from 'vue'
2、监视两种方法,属性ref,immediate deep可以直接写,比vue2简单
a、监听一个
// 第一种写法,监视 一个 immediate deep watch(num, (newVal, oldVal) => {console.log('num', newVal, oldVal) },{immediate: true, deep:true})
b、监听多个,watch可以写多个或数组, newVal和oldVal都是数组
// 第二种,监视多个 newVla和oldVal都是数组 watch([num, msg],(newVal, oldVal) => {console.log('num和msg监听', newVal, oldVal) },{immediate:true, deep: true})