vue非 Prop 的 Attribute

Attribute 继承

当组件返回单个根节点时,非 prop attribute 将自动添加到根节点的 attribute 中。

同样的规则适用于事件监听器

禁用 Attribute 继承

如果你不希望组件的根元素继承 attribute,你可以在组件的选项中设置 inheritAttrs: false

禁用 attribute 继承的常见情况是需要将 attribute 应用于根节点之外的其他元素。

需要Attribute继承,在元素上绑定 $attrs

https://vue3js.cn/docs/zh/guide/component-attrs.html#attribute-%E7%BB%A7%E6%89%BF

原文地址:https://www.cnblogs.com/shine-lovely/p/14713843.html