Skip to content

vue/no-v-for-template-key

disallow key attribute on <template v-for>

  • 🚫 This rule was deprecated.
  • ⚙️ This rule is included in all of "plugin:vue/vue2-essential", *.configs["flat/vue2-essential"], "plugin:vue/vue2-strongly-recommended", *.configs["flat/vue2-strongly-recommended"], "plugin:vue/vue2-recommended" and *.configs["flat/vue2-recommended"].

📖 Rule Details

This rule reports the <template v-for> elements which have key attribute.

In Vue.js 2.x, disallows key attribute on <template> elements.

Note

This rule is targeted at Vue.js 2.x. If you are using Vue.js 3.x, enable the vue/no-v-for-template-key-on-child rule instead. Don't enable both rules together; they are conflicting.

<template> <!-- ✓ GOOD --> <template v-for="item in list"> <div :key="item.id" /> </template> <!-- ✗ BAD --> <template v-for="item in list" :key="item.id"> <div /> </template> </template>
Now loading...

Note

If you want to report keys placed on <template> without v-for, use the vue/no-template-key rule.

🔧 Options

Nothing.

📚 Further Reading

🚀 Version

This rule was introduced in eslint-plugin-vue v7.0.0

🔍 Implementation