Scaling UpLesson 24Free preview
Vue Fallthrough Attributes
This lesson is part of Vue · All levels
Summary
Fallthrough attributes are attributes that are attached to a component tag but are not listed as props, such as a class, style, id, or specific data. Intuitively Vue inherits these attributes to the root element within the component template. If the component renders more than one root element, you need to set the inheritAttrs option or move the attribute manually.
Key points
- Attributes that are not props are called fallthrough attributes.
- Class and style are inherited to the root element automatically.
- The inheritAttrs option: false disables inheritance.
- The remaining attributes are available via the $attrs object on the template.
- Components with many root elements need to manually set the attributes.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.