Skip to content

vue/no-template-key ​

禁止在 <template> 上使用 key 属性

  • ⚙️ 此规则包含在 "plugin:vue/essential"、*.configs["flat/essential"]、"plugin:vue/vue2-essential"、*.configs["flat/vue2-essential"]、"plugin:vue/strongly-recommended"、*.configs["flat/strongly-recommended"]、"plugin:vue/vue2-strongly-recommended"、*.configs["flat/vue2-strongly-recommended"]、"plugin:vue/recommended"、*.configs["flat/recommended"]、"plugin:vue/vue2-recommended" 和 *.configs["flat/vue2-recommended"] 中。

Vue.js 不允许在 <template> 元素上使用 key 属性。

¥Vue.js disallows key attribute on <template> elements.

📖 规则详情 ​

此规则报告具有 key 属性的 <template> 元素。

¥This rule reports the <template> elements which have key attribute.

Now loading...

注意

此规则不报告放置在 <template v-for> 上的键。它适用于 Vue.js 3.x。如果你想报告放置在 <template v-for> 上的键对 Vue.js 2.x 无效,请使用 vue/no-v-for-template-key 规则。

¥This rule does not report keys placed on <template v-for>. It's valid for Vue.js 3.x. If you want to report keys placed on <template v-for> invalid for Vue.js 2.x, use vue/no-v-for-template-key rule.

🔧选项 ​

¥🔧 Options

无。

¥Nothing.

👫相关规则 ​

¥👫 Related Rules

📚扩展阅读 ​

¥📚 Further Reading

🚀版本 ​

¥🚀 Version

此规则在 eslint-plugin-vue v3.4.0 中引入

¥This rule was introduced in eslint-plugin-vue v3.4.0

🔍代码实现 ​

¥🔍 Implementation

eslint-plugin-vue v10.4 中文网 - 粤ICP备13048890号