Line data Source code
1 16 : <template>
2 0 : <div ref="container" />
3 : </template>
4 :
5 : <script setup lang="ts">
6 : import { onMounted, ref, watch } from 'vue'
7 :
8 0 : const props = defineProps<{
9 : renderFunction: () => HTMLElement
10 : }>()
11 :
12 0 : const container = ref<HTMLElement | null>(null)
13 :
14 0 : function renderContent() {
15 0 : if (container.value) {
16 0 : container.value.innerHTML = ''
17 0 : const element = props.renderFunction()
18 0 : container.value.appendChild(element)
19 : }
20 : }
21 :
22 0 : onMounted(renderContent)
23 :
24 0 : watch(() => props.renderFunction, renderContent)
25 : </script>
|