One, named slot
There are two ways to present something indeterminate in a wrapped component, or to add something to a wrapped component
-
Develop all the content that may be used in the future inside the component, and decide whether to show and hide “not flexible enough” based on whether the corresponding properties are passed when the user retrieves the component.
-
The expansion of the component is realized based on the slot scheme. The position is reserved when the package is packaged. After the position is left, different contents can be inserted into the slot position when the component is called in the later period
-
When using slots, try to use named slots. If you want to pass information to more than one slot, it is usually wrapped in a template
-
$slots records all slots
-
If the slot does not write the name attribute, the default is default
-
- $slots stores all the slot information
Scope slot
The data inside the component can also be used when calling the component and passing information to the slot