一、普通监听略过
二、监听数组
data() {
return {
arrData:[1,1,1,1,1,1]
}
},
watch: {
arrData: {
handler(newVal, oldVal) {
for (let i = 0; i < newVal.length; i++) {
if (oldVal[i] != newVal[i]) {
console.log(newVal)
}
}
},
deep: true
}
}
三、监听对象
data() {
return {
objData: {
title: 'test',
content:'test'
}
}
},
watch: {
objData: {
handler(newVal, oldVal) {
console.log(newVal)
},
deep: true
}
}