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:classdirective can coexist with the plainclassattribute. Default istrue.allowCoexistStyle(boolean) ...启用v-bind:style指令可以与普通style属性共存。默认值为true。¥
allowCoexistStyle(boolean) ... Enablesv-bind:styledirective can coexist with the plainstyleattribute. 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