mattelen / vue3-runtime-template

Vue component for compiling templates on the fly using a v-html like API
MIT License
47 stars 12 forks source link

Components are not resolved from parent component #14

Open PadreSVK opened 1 year ago

PadreSVK commented 1 year ago

Hi, first of all thanks for your work 🎉

I am trying to use this library to dynamically render vuejs components, but I am not able to use custom components. image

by my understanding it should use components from parentOptions (I suppose that vue is doing some optimalization here)

Repro repository: https://github.com/PadreSVK/vue3-runtime-template-parent-elements-issue

karaaa006 commented 1 year ago

I have the same problem image

fork88888 commented 1 year ago

Personally for me working the following (Composition API Vue3):

For custom components that should be declared like components: { WelcomeItem } I use this._app.component("WelcomeItem", WelcomeItem); (It's better to use lowercase letter with "-" like "welcome-item")

And for instances that will be returned from setup() method: <v-runtime-template v-if="contentTemplate" :template="contentTemplate" :template-props="templateProps"></v-runtime-template> ... let templateProps = ref(); ... templateProps.value = result; ... return result = { active, loading, contentTemplate, templateProps }

So now you can use active, loading and component WelcomeItem inside your templete.