data() {
pwdForm: {
Content: '',
},
},
computed:{
Content(){ // 监听对象内的某个值1 配合计算属性使用
return this.pwdForm.Content
}
},
watch:{
// 改变后的值。改变前的值
Content(newValue, oldValue) { // 监听对象内的某个值1 配合计算属性使用
console.log(newValue,oldValue)
},
'pwdForm.Content'(newValue, oldValue) { // 监听对象内的某个值2
console.log(newValue)
},
pwdForm: { // 监听整个对象内的所有属性
handler(newValue, oldValue) { // 此函数变量名不能乱命名
console.log(newValue)
},
deep: true
}
},
借鉴 https://www.cnblogs.com/wanf/p/9184652.html