Vue報錯:Property or method "XXX" is not defined on the instance but referenced during render. Make sure that this property is reactive...


在Vue中定義方法或者屬性時,因為粗心疏忽可以能會報該錯誤

[Vue warn]: Property or method "search" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

屬性或方法“search”不是在實例上定義的,而是在呈現期間引用的。通過初始化該屬性,確保該屬性是反應性的,無論是在data選項中,還是對於基於類的組件。

 

可以檢查三個方面:

   1.是否將該屬性或方法放在 methods 中,尤其是methods 有沒有寫對。

   2.在methods中是否定義了該方法。

   3.如果方法中傳了參數,這個參數有沒有在 data 中 設置默認值

    以上三方面沒有解決:methods 中的方法的放的位置是否正確,括號太多了,可能發生嵌套錯誤。


免責聲明!

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



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