What Is Scoped Slots in Vue?

Scoped slots are a new feature in Vue 2.0 that allow developers to define custom slot types.

These slots can then be used to bind data to components or templates using the @slot directive.

In the example below, we have created a new slot type called “Message” and bound it to a component called “messageBox”. The @slot directive tells Vue that this is a slot type and that we want to use it to bind data to the component.

Hello, world!

We can now use the messageBox component in our app to display custom content. In the following example, we have created a new template called “hello-world.

vue” and bound it to our messageBox component. We can then use this template to display static content or respond to user input.

.

Related Posts