L
L
Little Vasya2018-06-11 08:33:23
Vue.js
Little Vasya, 2018-06-11 08:33:23

Why doesn't asynchronous component loading work in a VUEJS route?

I write like this:

const path = (components) => import(`./${components}.vue`)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'homepage',
      component: path(Home)
    },

  ]
})

But Js does not see it, writes is not defined

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lavezzi1, 2018-06-11
@lavezzi1

export default new Router({
  routes: [
    {
      path: '/',
      name: 'homepage',
      component: () => import('./Home.vue').then(m => m.default),
    },
  ]
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question