- 普通 watch
watch: {
value (newValue, oldValue) {
console.log(newValue)
}
}
- 数组 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)
}
}