vue watch怎样同时监听两个值的变化并执行方法?
用computed定义一个address对象吧,然后再去watch addresdata() {return {city: '',country: ''}},computed: {address() {const { city, country } = thisreturn {city,country...
·
用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
}
}
更多推荐
已为社区贡献5条内容
所有评论(0)