先用computed定义一个address对象,然后再去watch addres

 1 data() {
 2   return {
 3     city: '',
 4     country: ''
 5   }
 6 },
 7 computed: {
 8   address() {
 9     const { city, country } = this
10     return {
11       city,
12       country
13     }
14   }
15 },
16 watch: {
17   address(val){
18      console.log(val)
19  }
20 }

 

转载于:https://www.cnblogs.com/myunYao/p/10551921.html

Logo

Vue社区为您提供最前沿的新闻资讯和知识内容

更多推荐