Skip to content

vue/v-if-else-key

要求有条件渲染的重复组件有 key 属性

  • 🔧 command line 上的 --fix 选项可以自动修复此规则报告的一些问题。

📖 规则详情

此规则检查在同一范围内重复和有条件渲染的组件。如果找到这样的组件,则规则将检查是否存在 'key' 指令。如果缺少 'key' 指令,则规则触发警告并提供修复。

¥This rule checks for components that are both repeated and conditionally rendered within the same scope. If such a component is found, the rule then checks for the presence of a 'key' directive. If the 'key' directive is missing, the rule issues a warning and offers a fix.

Vue 3 中不需要此规则,因为键会自动分配给元素。

¥This rule is not required in Vue 3, as the key is automatically assigned to the elements.

Now loading...

🔧选项

¥🔧 Options

无。

¥Nothing.

👫相关规则

¥👫 Related Rules

📚扩展阅读

¥📚 Further Reading

🚀版本

¥🚀 Version

此规则是在 eslint-plugin-vue v9.19.0 中引入的

¥This rule was introduced in eslint-plugin-vue v9.19.0

🔍代码实现

¥🔍 Implementation

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