How can I make a component similar to vue-router router-link
where I get the tag via props to render my template ?
<my-component tag="ul">
</my-component>
Would render:
<ul>
anything inside my-component
</ul>
How can I make a component similar to vue-router router-link
where I get the tag via props to render my template ?
<my-component tag="ul">
</my-component>
Would render:
<ul>
anything inside my-component
</ul>
You can use a built-in
component
element like so:See: https://vuejs.org/v2/guide/components.html#Dynamic-Components
EDIT: Please check @krukid answer, it is a better solution, I didn't know about
component
element when I answeredRender function ways:
You need to create a "wrapper component" that use a render function.
then in any other template just use as follows
and that should render to this
To know more about render functions please see official documentation