2022-09-21 Property or method "xxx" is not defined on the instance but referenced during render.

完整报错:

[Vue warn]: Property or method "xxx" 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. 

这个xxx就是报错的变量,报错的意思是:

 

[Vue warn]:属性或方法“xxx”未在实例上定义,但在呈现期间被引用。
通过初始化属性,确保此属性在数据选项或基于类的组件中是反应性的。

也就是说,xxx这个变量被定义了,但是你没有使用,从而导致报错。

但事实上你觉得已经定义并且使用了对不对?

好,我们直接看data:

  data() {
    return {
      data: {
        xxx: '',
     }
  }

好家伙,data里面还有一个data。问题已经很显然了,data定义xxx变量的地方写错了

 

posted @ 2022-09-21 19:36  叶乘风  阅读(808)  评论(0编辑  收藏  举报