Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic element #10989

Closed
jonex2 opened this issue Jan 7, 2020 · 6 comments
Closed

Add dynamic element #10989

jonex2 opened this issue Jan 7, 2020 · 6 comments

Comments

@jonex2
Copy link

@jonex2 jonex2 commented Jan 7, 2020

What problem does this feature solve?

When you have an element similar to dynamic components in this way:

<element :is="[expression evaluating to string]"></element>

you dont't need to use render functions for dynamic creating elements.
in this case https://vuejs.org/v2/guide/render-function.html, it could be

<element :is="'h' + level">...

What does the proposed API look like?

<element :is="[expression evaluating to string]"></element>
@posva

This comment has been minimized.

Copy link
Member

@posva posva commented Jan 7, 2020

you can already do <component :is="expression" />

@posva posva closed this Jan 7, 2020
@jonex2

This comment has been minimized.

Copy link
Author

@jonex2 jonex2 commented Jan 8, 2020

I know that there exists dynamic components!
But i don't want to load a component dynamically but have the possibility to define an html element in the template dynamically (in order to avoid hard to read render functions). In the example above you could use dynamic components but you have to create 6 components (one for each headline)!
Please reopen the issue!

@jacekkarczmarczyk

This comment has been minimized.

Copy link

@jacekkarczmarczyk jacekkarczmarczyk commented Jan 8, 2020

<component :is="`h` + level">
@jonex2

This comment has been minimized.

Copy link
Author

@jonex2 jonex2 commented Jan 8, 2020

<component :is="`h` + level">

Yes, in this case you have to create 6 components with the name h1, h2, h3, h4, h5, h6 and thats inconvenient!

@posva

This comment has been minimized.

Copy link
Member

@posva posva commented Jan 8, 2020

You don't need to create 6 components, is allows specifying the name of an element or component, try it out before saying it doesn't work please.

Remember you can (and should) use the forum or the Discord chat to ask quick questions!

@jonex2

This comment has been minimized.

Copy link
Author

@jonex2 jonex2 commented Jan 8, 2020

You are right it works! The documentation doesn't mention this as far as i can see. There stands only you can use component name or component object (which has props for name and template). Also the example for render function is misleading in a way, it's not a practical use, in this case you would go better with the dynamic component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.