You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A component non-prop attribute is an attribute or event listener that is passed to a component, but does not have a corresponding property defined in [props](component-props)or[emits](component-custom-events.html#defining-custom-events). Common examples of this include `class`, `style`, and `id`attributes.
When a component returns a single root node, non-prop attributes will automatically be added to the root node's attributes. For example, in the instance of a date-picker component:
In the event we need to define the status of the date-picker component via a `data-status`property, it will be applied to the root node (i.e.,`div.date-picker`).
In this case, `change`event listener is passed from the parent component to the child and it will be triggered on native `<select>``change`event. We won't need to emit an event from the `date-picker`explicitly:
By setting the `inheritAttrs`option to `false`, this gives you access to the component's `$attrs`property, which includes all attributes not included to component `props`and`emits` properties (e.g., `class`, `style`, `v-on`listeners, etc.).
Using our date-picker component example from the [previous section]('#attribute-inheritance), in the event we need to apply all non-prop attributes to the `input` element rather than the root `div` element, this can be accomplished by using the `v-bind`shortcut.
<!-- Date-picker component with a non-prop attribute -->
@@ -109,16 +109,16 @@ With this new configuration, our `data-status` attribute will be applied to our
109
109
</div>
110
110
```
111
111
112
-
## Attribute Inheritance on Multiple Root Nodes
112
+
## ルート要素が複数の場合の属性の継承
113
113
114
-
Unlike single root node components, components with multiple root nodes do not have an automatic attribute fallthrough behavior. If `$attrs`are not bound explicitly, a runtime warning will be issued.
0 commit comments