routes: [
{
// ,"/"home
path: "/",
component: resolve => require(["../pages/home.vue"], resolve),
meta: {
title: "home"
}
}]
componentresolve => requirecomponent
routes: [
{
// ,"/"home
path: "/",
component: resolve => require(["../pages/home.vue"], resolve),
meta: {
title: "home"
}
}]
componentresolve => requirecomponent
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:
require(['./a', './b'], function(a, b){
console.log(a, b)
});
require.ensure([], function(require){
var a = require('./a');
console.log(a)
});
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'
}
}
Previous: How to judge that this kind of object is empty?
Next: The input content of input is not fully displayed in ios system.
vue-cli generated projects use lazy loading of routes; projects have more routes, but some routes do not jump to each other. Users may only operate under a certain route, . how do I extract a third-party library when multiple routing components intr...