I'm trying to make the components work. I want to have component names in the array, then import components as async and then somehow put the variable into app.component. I've been trying for about 6 hours here and I can't figure it out. I don't want to have 50x import and 50x app.component for each component and it doesn't want to work for me I'm probably missing something obvious. Unfortunately, I'm not that good at JS.
main.js
import { createApp, defineAsyncComponent } from "vue";
import App from "./App.vue";
import router from "./router";
var subComponents = new Array([
"test",
"test2"
]);
subComponents.forEach(subComponent => {
subComponent = defineAsyncComponent(() =>
import(`@/components/sub/${subComponent}.vue`)
)
});
const app = createApp(App);
app.use(router);
app.component(subComponent, subComponents);
app.mount("#app");
It reports these problems
Failed to resolve component: test
Failed to resolve component: test2