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 中的方法的放的位置是否正确,括号太多了,可能发生嵌套错误。

原文地址:https://www.cnblogs.com/chenpiaoxiaowu/p/11839828.html