Vue watch同時監聽到兩個值的變化


data() {
  return {
    //定義的兩個變量
    city: '',
    country: ''
  }
},
computed: {
    //寫成計算屬性
 address() {
    const { city, country } = this;
    return {
      city,
      country
    }
  }
},
watch: {
  address(nval, oval){
    // 其中 nval 和 oval 對象的形式==>{city:'',country:''}
     console.log('變化',nval,oval)
 }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM