vue watch同时监听两个值的变化并执行方法

先用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 }

 

posted @ 2019-03-18 14:16  呀,西蓝花  阅读(5711)  评论(0编辑  收藏  举报