021:尚硅谷watch监控情况5学习示例
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="person">
|
<div class="person">
|
||||||
<h1>情况4示例</h1>
|
<h1>情况5示例</h1>
|
||||||
<h2>姓名:{{ person.name }}</h2>
|
<h2>姓名:{{ person.name }}</h2>
|
||||||
<h2>年龄:{{ person.age }}</h2>
|
<h2>年龄:{{ person.age }}</h2>
|
||||||
<h2>汽车:{{ person.car.c1 }}---{{ person.car.c2 }} </h2>
|
<h2>汽车:{{ person.car.c1 }}---{{ person.car.c2 }} </h2>
|
||||||
@@ -49,10 +49,10 @@
|
|||||||
c2: '法拉利'
|
c2: '法拉利'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
watch(()=>person.age, (newValue, oldValue) => {
|
// watch(()=>person.age, (newValue, oldValue) => {
|
||||||
console.log('person changed:', newValue, oldValue)
|
// console.log('person changed:', newValue, oldValue)
|
||||||
})
|
// })
|
||||||
watch(()=>person.car, (newValue, oldValue) => {
|
watch([person.car,()=>person.name], (newValue, oldValue) => {
|
||||||
console.log('汽车变化了:', newValue, oldValue)
|
console.log('汽车变化了:', newValue, oldValue)
|
||||||
},{deep:true})
|
},{deep:true})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user