I have a page in nuxt that is divided in two parts. The first part is a normal template structure filled with dynamic content based on the url param. The second part is a component that should be loaded based on this data. I am trying to accomplish it like this:
<template>
<div>
<h1>{{myData.header}}</h1>
<p>{{myData.text}}</p>
<my-component></my-component>
</div>
</template>
<script>
export default {
components: {
'my-component': () => import('@/components' + this.myData.component)
},
async asyncData(context) {
return {
myData: context.params.myData
}
}
}
</script>
But this is not working. Is there a way to accomplish this?
I am familiar with the possibility to use <my-component :is="myData.component"></my-component>
. However, this requires me to import every component explicitly and I would like to avoid this.