Skip to content

vue/valid-v-else

强制有效的 v-else 指令

  • ⚙️ 此规则包含在 "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"] 中。

此规则检查每个 v-else 指令是否有效。

¥This rule checks whether every v-else directive is valid.

📖 规则详情

此规则在以下情况下报告 v-else 指令:

¥This rule reports v-else directives in the following cases:

  • 该指令有该参数。例如<div v-if="foo"></div><div v-else:aaa></div>

    ¥The directive has that argument. E.g. <div v-if="foo"></div><div v-else:aaa></div>

  • 该指令具有该修饰符。例如<div v-if="foo"></div><div v-else.bbb></div>

    ¥The directive has that modifier. E.g. <div v-if="foo"></div><div v-else.bbb></div>

  • 该指令有该属性值。例如<div v-if="foo"></div><div v-else="bar"></div>

    ¥The directive has that attribute value. E.g. <div v-if="foo"></div><div v-else="bar"></div>

  • 该指令位于前一个元素没有 v-if/v-else-if 指令的元素上。例如<div v-else></div>

    ¥The directive is on the elements that the previous element don't have v-if/v-else-if directives. E.g. <div v-else></div>

  • 该指令位于具有 v-if/v-else-if 指令的元素上。例如<div v-if="foo" v-else></div>

    ¥The directive is on the elements which have v-if/v-else-if directives. E.g. <div v-if="foo" v-else></div>

Now loading...

🔧选项

¥🔧 Options

无。

¥Nothing.

👫相关规则

¥👫 Related Rules

🚀版本

¥🚀 Version

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

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

🔍代码实现

¥🔍 Implementation

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