I have many components, i want to import then on demand. i have a drop down which actually contains components list, that what to load. I tried this example
<component :is="componentLoader"></component>
in script
componentLoader () {
return () => import('@/components/testDynamic')
}
testDynamic is a component name(For now i am trying with static component).
Getting this error
GET http://localhost:8080/0.js net::ERR_ABORTED 404
[Vue warn]: Failed to resolve async component: function () {
return __webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, "./src/components/testDynamic.vue"));
}
Reason: Error: Loading chunk 0 failed.
How to fix this? am i doing any thing wrong? or is there any other way to import components dynamically?
return () => require('@/components/testDynamic')