Skip to content

How does component render empty nodes? #12245

Answered by Wei-Ba
yoyo837 asked this question in Help/Questions
Discussion options

You must be logged in to vote
<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)
}

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@yoyo837
Comment options

@Hetari
Comment options

Comment options

You must be logged in to vote
1 reply
@yoyo837
Comment options

Answer selected by yoyo837
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants