【问题标题】:Elements in iteration expect to have 'v-bind:key' directives.eslint-plugin-vue迭代中的元素期望有 'v-bind:key' 指令。eslint-plugin-vue
【发布时间】:2021-10-13 02:05:17
【问题描述】:

寻求帮助我为什么会出错

"[vue/require-v-for-key]
Elements in iteration expect to have 'v-bind:key' directives.eslint-plugin-vue"

在我的 post.vue 上

[vue/require-v-for-key] 迭代中的元素期望有'v-bind:key' directives.eslint-plugin-vue

enter image description here

【问题讨论】:

  • 你需要在 v-for 循环中添加 key (v-for="row in data" :key="row.id")

标签: vue.js


【解决方案1】:

您始终必须将键绑定到您的元素。在您的情况下,这将是行中的 id。

<tr 
  v-for="row in data"
  v-bind:key = "row.id"
>

【讨论】:

    猜你喜欢
    • 2021-06-22
    • 2018-05-16
    • 2021-03-26
    • 2020-09-25
    • 2019-06-11
    • 2020-10-09
    • 1970-01-01
    • 2021-07-28
    • 2022-12-10
    相关资源
    最近更新 更多