zoukankan      html  css  js  c++  java
  • vue使用v-for时vscode报错 Elements in iteration expect to have 'v-bind:key' directives

    vue使用v-for时vscode报错 Elements in iteration expect to have 'v-bind:key' directives

    Vue 2.2.0+的版本里,当在组件中使用v-for时,key是必须的
    错误提示:
    [vue-language-server] Elements in iteration expect to have 'v-bind:key' directives.
    Renders the element or template block multiple times based on the source data
    原因是eslint检测出现bug
    ---------------------
    解决方法:
    1.在v-for 后添加 :key='item'
    <li v-for="i in list" :key="i">

    <div class="item" v-for="(user,index) in datalist" :key='index' >

    2.在build处关闭eslint检测
    ...(config.dev.useEslint ? [createLintingRule()] : []),

    3.更改vetur配置 vscode->首选项->设置->搜索(vetur)
    "vetur.validation.template": true,
    改成:false

  • 相关阅读:
    HDU 1874 畅通工程续
    HDU 1232 畅通工程
    HDU 1233 还是畅通工程
    HDU 1269 迷宫城堡
    洛谷 P1078 文化之旅
    POJ 3461 Oulipo
    最长链
    矩形面积求并
    有趣的数
    修复公路
  • 原文地址:https://www.cnblogs.com/zdz8207/p/vue-for-v-bind-key.html
Copyright © 2011-2022 走看看