Appearance
vue/no-confusing-v-for-v-if
禁止在同一个
v-for上混淆v-for和v-if元素
- ⛔ 此规则已在 eslint-plugin-vue v9.0.0 中删除,并由 vue/no-use-v-if-with-v-for 规则替换。
📖 规则详情
此规则报告在以下情况下同时具有 v-for 和 v-if 指令的元素:
¥This rule reports the elements which have both v-for and v-if directives in the following cases:
v-if指令不使用对v-for指令定义的变量的引用。¥The
v-ifdirective does not use the reference which is to the variables which are defined by thev-fordirectives.
在这种情况下,v-if 应该写在封装器元素上。
¥In that case, the v-if should be written on the wrapper element.
注意
当它们存在于同一节点时,v-for 的优先级高于 v-if。这意味着 v-if 将在循环的每次迭代中单独运行。
¥When they exist on the same node, v-for has a higher priority than v-if. That means the v-if will be run on each iteration of the loop separately.
https://vuejs.org/guide/essentials/list.html#v-for-with-v-if
🔧选项
¥🔧 Options
无。
¥Nothing.
📚扩展阅读
¥📚 Further Reading
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v3.0.0 中引入
¥This rule was introduced in eslint-plugin-vue v3.0.0
🔍代码实现
¥🔍 Implementation