Skip to content Skip to sidebar Skip to footer

Vuejs Lazy Loading Routes In Webpack Template

I have created vuejs project with vue-cli tools and webpack template. vue init webpack my-project I don't know how to implement lazy loading on routes with templates currently i h

Solution 1:

instead of using

importTestfrom'@/components/Test'

use as

const Test = () => import('@/components/Test');

lazy loading Documentataion

Solution 2:

Nice way to do this:

functionload (component) {
  return() =>import(`@/${component}.vue`)
}

...
routes: [
    { path: '/', component: load('Hello') },

Post a Comment for "Vuejs Lazy Loading Routes In Webpack Template"