欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue 中使用 watch 出現(xiàn)了如下的報錯的原因分析

 更新時間:2019年05月21日 08:35:57   作者:獨釣寒江雪  
這篇文章主要介紹了vue 中使用 watch 出現(xiàn)了如下的報錯信息的原因分析及解決方法,本文附有代碼解決方案,非常不錯,需要的朋友可以參考下

報錯: Method "watch" has type "object" in the component definition. Did you reference the function Method "watch" has type "object" in the component definition. Did you reference the function correctly?

  原因: watch 是一個對象,應該以鍵值對的形式來使用,但是我 將 watch 放到了 methods: {} 中,導致了這個問題;

  解決辦法:  將watch 對象 拿出來,與 methods 平級;

附上當時的代碼:

watch: {
  "$route.path":function(newval){
   if(newval === '/home'){
   this.flag = false
   }else{
   this.flag = true
   }
  }
  }
 }

總結

以上所示是小編給大家介紹的vue 中使用 watch 出現(xiàn)了如下的報錯的原因分析,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復大家的!

相關文章

最新評論