Skip to content

vue/no-duplicate-attr-inheritance

在使用 v-bind="$attrs" 时强制将 inheritAttrs 设置为 false

¥enforce inheritAttrs to be set to false when using v-bind="$attrs"

📖 规则详情

此规则旨在防止重复的属性继承。此规则建议在检测到正在使用 v-bind="$attrs" 时应用 inheritAttrs: false

¥This rule aims to prevent duplicate attribute inheritance.\ This rule suggests applying inheritAttrs: false when it detects v-bind="$attrs" being used.

Now loading...
Now loading...

🔧选项

¥🔧 Options

json
{
  "vue/no-duplicate-attr-inheritance": ["error", {
    "checkMultiRootNodes": false,
  }]
}
  • "checkMultiRootNodes":如果设置为 true,还建议在检测到使用 v-bind="$attrs" 时将 inheritAttrs: false 应用于具有多个根节点的组件(其中 inheritAttrs: false 是隐式默认值,请参阅 多个根节点上的属性继承)。默认值为 false,它将忽略具有多个根节点的组件。

    ¥"checkMultiRootNodes": If set to true, also suggest applying inheritAttrs: false to components with multiple root nodes (where inheritAttrs: false is the implicit default, see attribute inheritance on multiple root nodes), whenever it detects v-bind="$attrs" being used. Default is false, which will ignore components with multiple root nodes.

"checkMultiRootNodes": true

Now loading...

📚扩展阅读

¥📚 Further Reading

🚀版本

¥🚀 Version

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

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

🔍代码实现

¥🔍 Implementation

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