JS.VUE.REQUIRE.V.FOR.KEY

Require 'v-bind:key' with 'v-for' directives

Rule Details

This rule reports the elements which have v-for and do not have v-bind:key with exception to custom components.

{'vue/require-v-for-key': ['error']}

Copy
<template>
  <!-- GOOD -->
  <div
    v-for="todo in todos"
    :key="todo.id"
  />
  <!-- BAD -->
  <div v-for="todo in todos"/>
</template>

This rule does not report missing v-bind:key on custom components. It will be reported by valid-v-for rule.

Options

Nothing.

Further Reading

  • Style guide - Keyed v-for (https://vuejs.org/style-guide/rules-essential.html#use-keyed-v-for)
  • Guide (for v2) - v-for with a Component (https://v2.vuejs.org/v2/guide/list.html#v-for-with-a-Component)

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/