So i created the following method to render a webcomponent:
export function renderComponent(el: Element, component: Component,props: VNodeProps,appContext: AppContext){
let vnode: VNode | undefined = createVNode(component, props)
vnode.appContext = { ...appContext }
render(vnode, el)
return ()=> {
render(null, el)
vnode = undefined
}
}
i tried using it like this in my componentView.vue:
const addComponent = async(component: ComponentRegistryItem) => {
destroyComp = renderComponent(
containerDiv.value,
(await import (/* @vite-ignore */ component.frontendUrl)),
{},
appContext);
};
And i have this template:
<li v-for="component in group">
<button @click="addComponent(component)">{{ component.tagName }}</button>
<div ref="containerDiv"></div>
</li>
the component.frontendUrl is a javascript webcomponent extending HTMLElement (non vue), But when i press the button i do not get any error, just nothing happens.
Does any one know how to render a non vue component?
UPDATE:
when i log the imported component i see :
Object { … }
Symbol(Symbol.toStringTag): "Module"
html-code-block