watch: {
// 方法监听
myValue(newValue){
debugger
this.$emit('input',newValue)
console.log(this.value,"我是子组件value");
},
// 对象监听
// 1.对象属性监听
myValue: {
handler(newValue,oldValue){
},
immediate: true,
deep: true
},
// 2.对象属性监听简写,因为监听对象实际上是监听对象属性的变化
"student.name": {
handler(newValue,oldValue){}
}
"student.name"(newValue,oldValue){
}
}
watch结合computed
watch: {
personalbar(newValue,oldValue){
console.log(newValue);
}
}
computed: {
personalbar(){
return this.student.name;
}
}