當建立一個vue物件
如果data內容是由變數動態產生
要watch這些動態data值 可以透過this$watch建立
 const dataObj = {  
  x:'',  
  y:''  
 }  
 建立vue物件  
 {  
  data() {  
   return dataObj  
  },  
  created() {  
   for(const prop in dataObj) {  
    this.$watch(prop, function(newValue, oldValue) {  
     // .. do something  
    });  
   }  
  }  
 }  
 
沒有留言:
張貼留言