P粉5949413012023-09-01 00:07:29
I solved this problem by using ref on the template tag and then using the render
function.
<template id="some-id" ref="someRef"> </template>
const someRef: Ref<HTMLTemplateElement | undefined> = ref() onMounted(() => { if (someRef.value?.content) { // @ts-ignore render('div', someRef.value.content) } })
If you want to insert a component, you can use it like this:
const someRef: Ref<HTMLTemplateElement | undefined> = ref() onMounted(() => { if (someRef.value?.content) { // @ts-ignore render(h(SomeComponent, { someProp: someValue }), someRef.value.content) } })
There may be better ones, but it works for now.