What does component: (resolve) = > require mean?

routes: [

{
  // ,"/"home
  path: "/",
  component: resolve => require(["../pages/home.vue"], resolve),
  meta: {
    title: "home"
  }
}]
componentresolve => requirecomponent
Apr.28,2022

this is written for ide/components-dynamic-async.html-sharp%E5%BC%82%E6%AD%A5%E7%BB%84%E4%BB%B6" rel=" nofollow noreferrer "> Asynchronous components

resolve is the resolve callback of promise , which is called after the component is loaded successfully.

because webpack supports multiple module specification syntax, there are many ways to load asynchronously:

AMD async

require(['./a', './b'], function(a, b){
    console.log(a, b)
});

commonjs async

require.ensure([], function(require){
    var a = require('./a');
    console.log(a)
});

ES async

import('./a').then(a => {
    console.log(a)
})

this is an asynchronous loading component. Home.vue will only be loaded when you visit /.
but this way of writing is out of date. It is recommended to use import ('.. / home.vue')


to change the absolute path to


.

br > can also be written as follows. Refer to ide/advanced/lazy-loading.html" rel=" nofollow noreferrer "> document

.
{
  path: '/',
  component: () => import('../pages/home.vue'),
  meta: {
    title: 'home'
  }
}
Menu