-
Hello all. I'm trying to get runtime compilation to work so that I can dynamically show components obtained from a backend CMS (public resources are compiled statically, but some contents require specific permissions and thus are dynamically handled). I am struggling with getting the component to render. The dynamic component I have is specified as follows: const dynamicComponent = computed(() => {
return markRaw(defineComponent({
template: rendered.value
}))
}); And in the template as: <component :is="dynamicComponent" v-if="dynamicComponent"></component> When I tried this, I got a warning from vue, indicating me to use the following alias in my config (which I added to the
It works in
After some research I found that most people had success by importing the
However, after that, when I try to run
Basically, I'd like to know how to dynamically compile vue components from strings in vitepress. I'll be 100% honest and admit I don't know much about the internal structure of vite and vue (though if anyone has any good resources to learn I'll gladly read up on them). Thanks in advance for any help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Your alias should be like this - #2448 (comment) When you write just |
Beta Was this translation helpful? Give feedback.
Your alias should be like this - #2448 (comment)
When you write just
vue
it matchesimport {} from 'vue/server-renderer'
too. That's why it turns tovue/dist/vue.esm-bundler.js/server-renderer