Excuse me, is it possible to optimize the rendering of component
?
#13485
eveningwater
started this conversation in
General Discussions
Replies: 1 comment 1 reply
-
There's an RFC proposing a new directive, At the moment, I think the best you can do is to introduce a new component to do the conditional rendering. e.g.: const Wrapper = ({ tag }, { slots }) => {
if (tag) {
return h(tag, null, slots)
} else {
return slots.default?.()
}
}
Wrapper.props = ['tag'] |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
example
This does not render child elements. I have an application scenario, that is, I may need a button group to render a button list, but this button group container element is not necessary. At this time, I want to use the
component
element to render it.Of course, I also know that I can use 2 template elements plus v-if and v-else to handle it, such as:
But writing like this will make the template look bloated.
Beta Was this translation helpful? Give feedback.
All reactions