Subscribe on changes!

v-if does not work on slots.name in vue 3 while it works in vue 2

avatar
Jan 29th 2022

Version

3.2.29

Reproduction link

sfc.vuejs.org/

Steps to reproduce

There does not seem to be a way to disable slots if they have not been provided or if they end up being empty (maybe a null or undefined in a variable send to the slot)

What is expected?

I would expect the whole

to not be rendered using v-if="slots.heading" or a similar syntax

What is actually happening?

slots.heading is undefined and there does not seem to be any other way to access whether a slot is defined or empty


This seems like a base feature to me - there are plenty of components I have which I would like to convert from vue 2 to vue 3 which have borders and other tags around a slot but which should not be rendered it he slot was not provided...

Even if slots.slot-name is not provided to the template, at least provide some functions which can be called to check...

avatar
Jan 29th 2022

should be v-if="$slots.heading"

avatar
Jan 29th 2022

Thanks @edison1105 , you know I promise I tried that like 5 times, but I must have had a typeo somewhere. Seems to work thanks 😅