default) content for a slot, to be rendered only when no content is provided. There are cases when it’s useful to specify fallback (i.e.
For example, trying to access url would not work: Ĭlicking here will send you to: Įverything in the parent template is compiled in parent scope everything in the child template is compiled in the child scope. The slot does not have access to ‘s scope. the same “scope”) as the rest of the template. That slot has access to the same instance properties (i.e. When you want to use data inside a slot, such as in: If ‘s template did not contain a element, any content provided between its opening and closing tag would be discarded. Slots can contain any template code, including HTML: When the component renders, will be replaced by “Your Profile”. Then in the template for, you might have: This allows you to compose components like this: Vue implements a content distribution API inspired by the Web Components spec draft, using the element to serve as distribution outlets for content. The rationale for introducing the new syntax is described in this RFC. It replaces the slot and slot-scope attributes, which are now deprecated, but have not been removed and are still documented here. In 2.6.0, we introduced a new unified syntax (the v-slot directive) for named and scoped slots. Read that first if you are new to components. This page assumes you’ve already read the Components Basics.