Appearance
vue/html-button-has-type
禁止使用没有明确类型属性的按钮
¥disallow usage of button without an explicit type attribute
如果忘记按钮上的 type 属性,则默认为提交类型。这几乎从来都不是预期的,特别是在你的普通单页应用中。
¥Forgetting the type attribute on a button defaults it to being a submit type. This is nearly never what is intended, especially in your average one-page application.
📖 规则详情
此规则旨在警告按钮类型属性上是否未使用类型或使用无效类型。
¥This rule aims to warn if no type or an invalid type is used on a button type attribute.
Now loading...
🔧选项
¥🔧 Options
json
{
"vue/html-button-has-type": ["error", {
"button": true,
"submit": true,
"reset": true
}]
}
button
...<button type="button"></button>
true
(默认)...允许值button
。¥
true
(default) ... allow valuebutton
.false
...禁止值button
。¥
false
... disallow valuebutton
.
submit
...<button type="submit"></button>
true
(默认)...允许值submit
。¥
true
(default) ... allow valuesubmit
.false
...禁止值submit
。¥
false
... disallow valuesubmit
.
reset
...<button type="reset"></button>
true
(默认)...允许值reset
。¥
true
(default) ... allow valuereset
.false
...禁止值reset
。¥
false
... disallow valuereset
.
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v7.6.0 中引入
¥This rule was introduced in eslint-plugin-vue v7.6.0
🔍代码实现
¥🔍 Implementation