info is an object
//第一种
watch: {
info(newValue,oldValue) {
console.log(newValue)
}
}
//第二种
watch: {
info: {
handler(newValue, oldValue) {
console.log(newValue)
},
deep: true
}
}
The difference is that: first info only be reassigned to be effective (v-model binding property values info when the listener does not take effect)
will take effect when the second when the info object properties change
Other methods:
1. by calculating properties
computed: {
info() {
....
}
},
2. For property listens
'info.name'(newValue, oldValue) {
console.log(newValue)
}