How does component render empty nodes? #12245
-
<component :is="bool ? 'div' : '<></>'">
children
</components>
It don't works. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
I think <div v-if="bool">
children
</div> is what you want |
Beta Was this translation helpful? Give feedback.
-
The To achieve what you want in Vue you use 1. Conditional Rendering with
|
Beta Was this translation helpful? Give feedback.
-
<component :is="show ? 'div' : {setup: (_, {slots}) => () => renderSlot(slots, 'default')}">
<slot/>
</component> ... <template v-if="!is"><slot/></template>
<component v-else :is="is"><slot/></component> ... setup(props, { slots }){
const w = (vnode, tag) => !is ? vnode : h(tag, vnode)
return () => w(renderSlot(slots, 'default'), props.is)
} |
Beta Was this translation helpful? Give feedback.
...
...