Skip to content

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.

Now loading...

🔧选项

¥🔧 Options

json
{
  "vue/no-duplicate-attributes": ["error", {
    "allowCoexistClass": true,
    "allowCoexistStyle": true
  }]
}
  • allowCoexistClass (boolean) ...启用 v-bind:class 指令可以与普通 class 属性共存。默认值为 true

    ¥allowCoexistClass (boolean) ... Enables v-bind:class directive can coexist with the plain class attribute. Default is true.

  • allowCoexistStyle (boolean) ...启用 v-bind:style 指令可以与普通 style 属性共存。默认值为 true

    ¥allowCoexistStyle (boolean) ... Enables v-bind:style directive can coexist with the plain style attribute. Default is true.

"allowCoexistClass": false, "allowCoexistStyle": false

Now loading...

🚀版本

¥🚀 Version

此规则在 eslint-plugin-vue v3.0.0 中引入

¥This rule was introduced in eslint-plugin-vue v3.0.0

🔍代码实现

¥🔍 Implementation

eslint-plugin-vue v10.0 中文网 - 粤ICP备13048890号