Answer the question
In order to leave comments, you need to log in
How to dynamically load components without using vue-router?
Tell me if I have a project without vue-router (not SPA). Assembled in Webpack.
And it seems that the project itself is small, but the final js file is going to be decent. It turns out that everything has been compiled into one JS, and since pages are loaded with a reload, it loads it every time.
When using vue-router on projects, somehow I didn’t think about it, the components there were loaded dynamically depending on the route. And now it turns out I'm loading one page, but all the JS is loaded on each page with all the components that, in fact, I don't need.
Please tell me how to organize it.
Answer the question
In order to leave comments, you need to log in
Loading components does not depend on vue-router, but depends on how you connect them.
components: {
some: () => import('@/components/some.vue')
}
orVue.component('some', () => import('@/components/some.vue'));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question