vue.runtime.esm.js:4560 [Vue warn]: Property or method “item“ is not defined on the instance but

  • 报错异常

vue.runtime.esm.js:4560 [Vue warn]: Property or method “item” 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. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

在这里插入图片描述

  • 我的代码是这样的
<div   v-for="(item,index) in imagesList" :key="index+'image'" >
<!--Owner是我自己封装的组件 -->
<Owner :ownerListProp="item.userVos"></Owner>
</div>
  • 一开始我以为是for 循环里item的问题(被别的博客带了节奏)。
  • 我尝试把Owner 组件注释掉就没有这个警告了,随后我把Owner的代码每次注释一小段代码,然后调试,终于找到问题了,在Owner发现一个item,其实这里面是没有item变量的,是我复制粘贴的锅。
    在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/baidu_19473529/article/details/130889154