Open
Description
Info
How do we use the scoped slot?
difficulty: easy
title:How do we access the state of the child component when we use the slot?
tags: Slots
Question
In some cases, we need to get the child component's data from the parent component through the slot,
How do we use the scope slot?
Template
MyComponent .vue
<div>
<slot :text="greetingMessage" :count="1"></slot>
</div>
App.vue
<MyComponent v-slot="slotProps">
{{ slotProps.text }} {{ slotProps.count }}
</MyComponent>