1. Listen to objects

Watch (age, (newVal, oldVal) => {console.log('age changed ', newVal, oldVal)}) watch(stu, (newVal, OldVal) => {console.log('stu changed ', newVal, oldVal)}, {immediate: false, deep: false})Copy the code

2. Listen on the array, both of them together, if there is a change, execute

Watch ([age, stu], () => {console.log(' one changed ')})Copy the code

3. Listen for the return value of the function

watch(() => stu.address,
      (newVal, oldVal) => { console.log('stu.address', newVal, oldVal) },
      { immediate: false, deep: true }
    )
Copy the code