Vue3 Useslots

Posted on  by admin
Modified10 months ago.

Is there a Vue3 equivalent to the following Vue2 method:. in Vue3's Composition API? but it isn't returning the expected value as slots is undefined (per error out in console).

200200 bronze badges. As pointed out in comments, setup()'s second argument (the context) contains the component's slots. The first argument is for the component's props.

The slots are also exposed in the template as $slots, so you could replace hasSlot(slotName) with $slots[slotName] or just $slots.SLOTNAME (e.g., $slots.footer):.

1414 gold badges141141 silver badges200200 bronze badges. 200200 bronze badges. With the recent release of Vue 2.6, the syntax for using slots has been made more succinct.

Boussadjra Brahim

Experience your Vue apps exactly how a user does