Appearance
vue/v-on-event-hyphenation
在模板中的自定义组件上强制使用 v-on 事件命名样式
- ⚙️ 此规则包含在
"plugin:vue/strongly-recommended"
、*.configs["flat/strongly-recommended"]
、"plugin:vue/recommended"
和*.configs["flat/recommended"]
中。
🔧命令行 上的
--fix
选项可以自动修复此规则报告的一些问题。¥🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule.
📖 规则详情
此规则强制在 Vue 模板中的自定义组件上使用带连字符的 v-on 事件名称。
¥This rule enforces using hyphenated v-on event names on custom components in Vue templates.
🔧选项
¥🔧 Options
json
{
"vue/v-on-event-hyphenation": ["error", "always" | "never", {
"autofix": false,
"ignore": [],
"ignoreTags": []
}]
}
"always"
(默认)...使用带连字符的事件名称。¥
"always"
(default) ... Use hyphenated event name."never"
...不要使用带连字符的事件名称。¥
"never"
... Don't use hyphenated event name."ignore"
...不需要遵循指定大小写的事件名称数组。¥
"ignore"
... Array of event names that don't need to follow the specified casing."ignoreTags"
...标签名称数组,其事件不需要遵循指定的大小写。¥
"ignoreTags"
... Array of tag names whose events don't need to follow the specified casing."autofix"
...如果是true
,则启用自动修复。如果你使用的是 Vue 2,我们建议你不要使用它,因为它有副作用。¥
"autofix"
... Iftrue
, enable autofix. If you are using Vue 2, we recommend that you do not use it due to its side effects.
"always"
它会在大写字母上出错。
¥It errors on upper case letters.
"never"
连字符错误。
¥It errors on hyphens.
"never", { "ignore": ["custom-event"] }
不要使用带连字符的名称但允许自定义事件名称
¥Don't use hyphenated name but allow custom event names
"never", { "ignoreTags": ["/^custom-/"] }
👫相关规则
¥👫 Related Rules
📚扩展阅读
¥📚 Further Reading
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v7.4.0 中引入
¥This rule was introduced in eslint-plugin-vue v7.4.0
🔍代码实现
¥🔍 Implementation