Original directions: 78727063
The first type:
Introduction Method (Normal introduction):
New Router ({ routes: [ { '/hyh ', component:hyh, ' Hyh ' } ]})
The second type:
New Router ({ routes: [ { '/index ', + = { require (['... /components/index/index '], resolve)// Here is your module without import to introduce } } ]} )
The third type: Official recommendation
// R is resolve . List = r + = Require.ensure ([], () = R (Require ('.. /components/list/list '), ' list '); // routing is also a normal notation New Router ({ routes: [ { '/list/blog ', component:list, ' blog ' } ]})
Describes a way to manage routing
// define an array of routes similar to a whitelist blacklist
Const DEFAULTROUTERARR = ['/list/share ']
Router.beforeeach(to, from , next) = = {
if the array is matched to this
if (Defaultrouterarr.indexof (to.path) >= 0) {
// perform various operations such as getting him to log in, not letting her in. Control detailed reference Vue routing with the Next method
Next ()
} Else {
Next ()
}
})
Webpack three ways to implement lazy loading of routes