021:尚硅谷watch监控情况5学习示例

This commit is contained in:
heiye111
2025-10-02 15:36:29 +08:00
parent 22857ff559
commit 20907407c7

View File

@@ -1,6 +1,6 @@
<template>
<div class="person">
<h1>情况4示例</h1>
<h1>情况5示例</h1>
<h2>姓名{{ person.name }}</h2>
<h2>年龄{{ person.age }}</h2>
<h2>汽车{{ person.car.c1 }}---{{ person.car.c2 }} </h2>
@@ -49,10 +49,10 @@
c2: '法拉利'
}
}
watch(()=>person.age, (newValue, oldValue) => {
console.log('person changed:', newValue, oldValue)
})
watch(()=>person.car, (newValue, oldValue) => {
// watch(()=>person.age, (newValue, oldValue) => {
// console.log('person changed:', newValue, oldValue)
// })
watch([person.car,()=>person.name], (newValue, oldValue) => {
console.log('汽车变化了:', newValue, oldValue)
},{deep:true})