Improve rendering vue components programmatically #582
Replies: 5 comments
-
Totally agree! |
Beta Was this translation helpful? Give feedback.
-
You might be interested in this: https://vue-mountable.netlify.app/ As for your use case (displaying a graph of nodes of various types): wouldn't it work to simply bind a dynamic component in a <div>
<component
v-for="c of components"
:key="c.data.id"
:is="c.component"
v-bind="c.data"
/>
</div> In case you're not familiar with dynamic components: https://vuejs.org/guide/essentials/component-basics#dynamic-components |
Beta Was this translation helpful? Give feedback.
-
I want to render a vue component in my js plugin parent vue component what should i do to get it by set vnode |
Beta Was this translation helpful? Give feedback.
-
I think the official Teleport component is already available, and it's exactly what you want. |
Beta Was this translation helpful? Give feedback.
-
Rendering vue components programmatically
I think it would be great to have a standardized and a documented way to:
unmounted hook
.My thoughts on the method technical requirements
My knowledge on how to render a vue component programmatically & their drawbacks
Method 1: using
createApp().mount()
Advantages
Drawbacks
Method 2: using
render() & h()
Advantages
Drawbacks
getCurrentInstance
as we need to call it on asetup function
and pass the appContext)Why the hustle??
In some usecases we may need to run the vue components programmatically, for example, I am using a graph diagramming framework which gives me the ability to customize the way of rendering graph elements. so my plan was to use vue components for each graph element to get vue's powerful data binding and conditionals. here is working version of the implemented code:
Beta Was this translation helpful? Give feedback.
All reactions