DEV Community

Discussion on: The Magic of Vue's Dynamic Components For Lists of Data

Collapse
 
akselsoft profile image
Andrew MacNeill

In the above scenario, don't you still have to do an "import" in the script and components in the export default script?

I'm trying to avoid having to do an explicit import but still have the components generated dynamically with something like
computed: {
dynamicComponent () {
var x = this.compMe.trim().replace('components/', '')
return () => import(components/${x})
}
}

The problem is that since it's computed, it only ever gets the final component.

Any ideas?