- 普通 watch
watch: {
value (newValue, oldValue) {
console.log(newValue)
}
}
- 數(shù)組 watch
watch: {
arr: {
handler (newValue, oldValue) {
console.log(newValue)
},
deep: true
}
}
- 對象 watch
watch: {
obj: {
handler (newValue, oldValue) {
console.log(newValue)
},
deep: true
}
}
- 對象的具體屬性 watch
watch: {
'obj.name' (newValue, oldValue) {
console.log(newValue)
}
}