You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now the slot has access only to whole its component. It's nice but not enough if the slot is used in loop. Vue's scoped slot is example of how data is passed into slot.
A suggestion is to add a method to ComponentSlot object and use it like:
<!-- /resources/views/components/list.blade.php -->
<ul>
@foreach($carsas$car)
{{ $item->withBag($car) }} //<-- ComponentSlot's method withBag pass data to slot named 'item'
@endforeach
</ul>
In the slot we have a variable with predetermined name slotBag which contains passed data:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Now the slot has access only to whole its component. It's nice but not enough if the slot is used in loop. Vue's scoped slot is example of how data is passed into slot.
A suggestion is to add a method to ComponentSlot object and use it like:
In the slot we have a variable with predetermined name
slotBag
which contains passed data:It'll be really useful for lists and tables where every item has a set of own actions (show, edit, delete).
Beta Was this translation helpful? Give feedback.
All reactions