Appearance
vue/no-duplicate-attributes
禁止属性重复
- ⚙️ 此规则包含在
"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"]
中。
当组件上有多个同名的属性时,只使用最后一个,其余的将被忽略,所以这通常是一个错误。
¥When there are multiple attributes with the same name on a component, only the last one is used and the rest are ignored, so this is usually a mistake.
📖 规则详情
此规则报告重复的属性。v-bind:foo
指令被视为属性 foo
。
¥This rule reports duplicate attributes. v-bind:foo
directives are handled as the attribute foo
.
🔧选项
¥🔧 Options
json
{
"vue/no-duplicate-attributes": ["error", {
"allowCoexistClass": true,
"allowCoexistStyle": true
}]
}
allowCoexistClass
(boolean
) ...启用v-bind:class
指令可以与普通class
属性共存。默认值为true
。¥
allowCoexistClass
(boolean
) ... Enablesv-bind:class
directive can coexist with the plainclass
attribute. Default istrue
.allowCoexistStyle
(boolean
) ...启用v-bind:style
指令可以与普通style
属性共存。默认值为true
。¥
allowCoexistStyle
(boolean
) ... Enablesv-bind:style
directive can coexist with the plainstyle
attribute. Default istrue
.
"allowCoexistClass": false, "allowCoexistStyle": false
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v3.0.0 中引入
¥This rule was introduced in eslint-plugin-vue v3.0.0
🔍代码实现
¥🔍 Implementation