I use Vue 3 and I have a dynamic component. It takes a prop called componentName
so I can send any component to it. It works, kind of.
Part of the template
<component :is="componentName" />
The problem is that I still need to import all the possible components. If I send About
as a componentName
I need to import About.vue
.
Part of the script
I import all the possible components that can be added into componentName
. With 30 possible components, it will be a long list.
import About "@/components/About.vue";
import Projects from "@/components/Projects.vue";
Question
It there a way to dynamically import the component used?