Answer the question
In order to leave comments, you need to log in
How to dynamically load components?
Hello.
How to dynamically load components?
I get an array in props.
These components all lie in the same folder at the same level.
Is it possible to import them in a loop?
components:['Button','Checkbox']
Answer the question
In order to leave comments, you need to log in
You can simply store the components in an array rather than in the top-level components object, i.e.:
import SomeComponent from 'path/to/SomeComponent'
data: () => ({
items: [
{ component: SomeComponent }
]
})
<component :is="item.component" />
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question