In Vue.js, the <slot> element is used to serve as distribution outlets for content.
Let’s take an example to create an alert component with slots for content insertion.
Example:
In Vue.js, the <slot> element is used to serve as distribution outlets for content.
Let’s take an example to create an alert component with slots for content insertion.
Example:
- Vue.component(‘alert’, {
- template: `
- <div class=”alert-box”>
- <strong>Error!</strong>
- <slot></slot>
- </div>`
- })
We can insert dynamic content as follows:
- <alert>
- There is an issue with in application.
- </alert>