vue watchはどのようにして2つの値の変化を同時に傍受し、方法を実行しますか?
456 ワード
computedでaddressオブジェクトを定義してからwatch addresに行きます
data() {
return {
city: '',
country: ''
}
},
computed: {
address() {
const { city, country } = this
return {
city,
country
}
}
},
watch: {
address: {
handler: function(newval , oldval) {
console.log('address new =:' + newval );
console.log('address old =:' + oldval );
},
deep: true
}
}