当前位置:   article > 正文

报错 property or method “lists“ is not defined on the instance but referenced during render_property or method "list" is not defined on the in

property or method "list" is not defined on the instance but referenced duri

目录

一、问题

二、可能原因

三、解决方法

四、总结


一、问题

书写.vue文件时,报错property or method "lists" is not defined on the instance but referenced during render

1.详细错误

2. .vue文件

  1. <template>
  2. <select>
  3. <option v-for="list in lists">{{list.label}}</option>
  4. </select>
  5. </template>
  6. <script>
  7. export default{
  8. data(){
  9. return{
  10. lists:[
  11. {
  12. label:"111“,
  13. },
  14. {
  15. label:"222“,
  16. },
  17. {
  18. label:"000"+,
  19. }
  20. ]
  21. }
  22. }
  23. }
  24. </script>

二、可能原因

1.在.vue文件的data选项中没有返回  lists 这个属性

2.返回了lists属性,但是lists内部属性初始化错误

三、解决方法

1.检查 dada 选项中是否定义了  lists 这个属性。没有,则添加该属性和属性值。

2.有lists,则检查lists内部属性的初始化是否有错误,改正错误即可。

此处,则是第二个原因,lists中的  第三个对象 {label:"000"+,}多了一个 "+",删除“+”即可。

四、总结

1.报错 property or method "xxx" is not defined on the instance but referenced during render.不一定是  xxx 属性没有写,还有可能是 xxx 属性内部书写 错误

2.之所以说这个,是因为有时候浏览器调试工具定位错误 不精确,导致有时候报错了,可能半天 觉得自己没有错误,实际上错误是有的,只是 浏览器调试工具定位、提示不准确。---我自己就因为认为自己已经定义了 lists属性,半天不知道提示信息要表达什么意思,搞了好长时间才发现问题。

/*

希望对你有帮助!

如有错误,欢迎指正!

*/

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/315770
推荐阅读
相关标签
  

闽ICP备14008679号