Appearance
vue/valid-v-on
强制有效的
v-on指令
- ⚙️ 此规则包含在
"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-on 指令是否有效。
¥This rule checks whether every v-on directive is valid.
📖 规则详情
此规则在以下情况下报告 v-on 指令:
¥This rule reports v-on directives in the following cases:
该指令没有该事件名称。例如
<div v-on="foo"></div>¥The directive does not have that event name. E.g.
<div v-on="foo"></div>该指令有无效的修饰符。例如
<div v-on:click.bbb="foo"></div>¥The directive has invalid modifiers. E.g.
<div v-on:click.bbb="foo"></div>该指令没有该属性值和任何动词修饰符。例如
<div v-on:click></div>¥The directive does not have that attribute value and any verb modifiers. E.g.
<div v-on:click></div>
注意
此规则不检查指令中的语法错误,因为它由 vue/no-parsing-error 规则检查。
¥This rule does not check syntax errors in directives because it's checked by vue/no-parsing-error rule.
🔧选项
¥🔧 Options
json
{
"vue/valid-v-on": ["error", {
"modifiers": []
}]
}此规则有一个对象选项:
¥This rule has an object option:
"modifiers" 允许的其他修饰符数组。
¥"modifiers" array of additional allowed modifiers.
"modifiers": ["foo"]
👫相关规则
¥👫 Related Rules
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v3.11.0 中引入
¥This rule was introduced in eslint-plugin-vue v3.11.0
🔍代码实现
¥🔍 Implementation