Vue · VUE0045
Key v-for items that hold state
Reports v-for elements without a key when an item holds state: a component whose source keeps local state, an element with v-model, a native form control, or a child of <TransitionGroup>. Unkeyed lists of stateless elements are not reported.
Run this rule
pnpm vite-doctor . --framework vue --rules vue/template/require-v-for-key
Why it matters
Without a key, Vue patches a v-for list in place. When items are inserted, removed or reordered, each component instance and form control stays at its position, so local state, typed input and focus end up on a different item, and <TransitionGroup> does not animate unkeyed children at all.
Recommended fix
Bind
Useful links
Example
Key a component list by item id
Before
<script setup lang="ts">
import TodoRow from "./TodoRow.vue"; // keeps a draft in ref()
</script>
<template>
<TodoRow v-for="todo in todos" :todo="todo" />
</template>
After
<script setup lang="ts">
import TodoRow from "./TodoRow.vue"; // keeps a draft in ref()
</script>
<template>
<TodoRow v-for="todo in todos" :key="todo.id" :todo="todo" />
</template>