Vue2.0不同于Vue1.0版本,它把$index和$key都移除了,取而代之的是:key属性。

如果还像之前那样写的话会报Property or method "$index" 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.之类的错误。

Vue1.0版本的写法为:

<ul id="example"><li v-for="item in items">{{$index}}{{$key}}</li>
</ul>

Vue2.0版本的写法为:

<ul id="example"><li v-for="(item,index) in items" :key="item.index">{{item}}{{index}}</li>
</ul>

另一个办法是在build处关闭eslint检测(没试过)

...(config.dev.useEslint ? [createLintingRule()] : []),

参考:https://my.oschina.net/u/3986411/blog/2906924

和 https://www.jianshu.com/p/2cf1a0736154

vue 报错:Elements in iteration expect to have ‘v-bind:key‘ directives相关推荐

  1. vue解决v-for报错 [vue/valid-v-for]Custom elements in iteration require ‘v-bind:key‘ directives

    v-for报错 [vue/valid-v-for]Custom elements in iteration require 'v-bind:key' directives.eslint-plugin- ...

  2. 记Vue报错Custom elements in iteration require ‘v-bind:key‘ directives.“错误解决

    在使用v-for时会出现v-for报错 [vue/valid-v-for]Custom elements in iteration require 'v-bind:key' directives.es ...

  3. vue/require-v-for-key]Elements in iteration expect to have ‘v-bind:key‘ directives

    报错内容:[vue/require-v-for-key]Elements in iteration expect to have 'v-bind:key' directives.解决:加上v-bind ...

  4. vue使用报错记录(cli4):[vue/valid-v-for] Custom elements in iteration require ‘v-bind:key‘ direc

    问题: [vue/valid-v-for] Custom elements in iteration require 'v-bind:key' directives.eslint-plugin-vue ...

  5. Elements in iteration expect to have v-bind:key directives错误的解决办法

    一.错误如下 [eslint-plugin-vue] [vue/require-v-for-key] Elements in iteration expect to have 'v-bind:key' ...

  6. 解决: Elements in iteration expect to have ‘v-bind:key‘ directives

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 报错: Elements in iteration expect to have 'v-bind:k ...

  7. Error:Elements in iteration expect to have ‘v-bind:key‘ directives

    Error:Elements in iteration expect to have 'v-bind:key' directives 报错如下 解决办法 查看官网教程截取部分文字如下图 怎么解决呢? ...

  8. Vue报错:Error while running task D:\vue\forum:build with message‘spawn vue-cli-service ENOENT‘

    Vue报错:Error while running task D:\vue\vueforum\forum:build with message'spawn vue-cli-service ENOENT ...

  9. vue 报错unknown custom element解决方法

    vue 报错unknown custom element解决方法 参考文章: (1)vue 报错unknown custom element解决方法 (2)https://www.cnblogs.co ...

  10. vue 报错 Cannot read property ‘__ob__‘ of undefined的解决方法

    vue 报错 Cannot read property '__ob__' of undefined的解决方法 参考文章: (1)vue 报错 Cannot read property '__ob__' ...

最新文章

  1. GDC2016 Epic Games【Bullet Train】 新风格的VR-FPS的制作方法
  2. HTML的标签描述16
  3. 平方的观测值表概率_中央气象台:“三九”大概率不会比“二九”更冷
  4. spring beans源码解读之--bean definiton解析器
  5. Linux学习之系统编程篇: 阻塞信号集、未决信号集、自定义信号集
  6. 2018第一季度全球畅销手机排行出炉,苹果刷榜,小米三星各一款
  7. 650c公路车推荐_盘点2020年各价位高性价比入门公路车
  8. ruby的optparse使用小记
  9. 张朝阳:知识直播是长久的事情 商业模式将水到渠成
  10. 织梦内容模型管理(人才招聘)
  11. SIP协议及与Freeswitch的关系
  12. Microsoft Excel 教程 如何在 Excel 中隐藏或显示行或列?
  13. 奥维地图看历史影像_如何在奥维中使用中国资源卫星影像图 | 奥维互动地图浏览器...
  14. matlab变量命名中文,Matlab变量及命名规则
  15. 华为鸿蒙系统手机会卡吗,鸿蒙系统的手机,会像安卓一样越来越卡吗?
  16. panda经典四道题期末考核分享
  17. ChatGPT 爆火!谷歌、微软、百度纷纷下场?
  18. 快递单打印专家 免费
  19. R语言 Hurst指数计算
  20. 【转载】使用Pytorch进行图像分类,AI challenger 农作物病害分类竞赛源码解读

热门文章

  1. 信息安全管理体系认证
  2. java实现qq聊天室功能
  3. lua的使用(摘自luachina)
  4. 用代码生成炫酷的词云图—《你好,李焕英》
  5. 七龙纪2-戒指和项链属性说明
  6. 引用量超6000的语义分割经典论文DeepLabv3解读
  7. Ubuntu18.04系统安装并配置mosquitto
  8. 武汉市个人社保缴费证明网上打印操作流程
  9. 前端开发_HTML5_CSS部分-背景(background)
  10. 125页完整版智慧数据中台解决方案(附PPT全文)