//前面已定以404组件,这里作转发 let router404 = { path:'*', redirect:'/404', hidden:true }
if(to.matched.length !== 0 ){ next() //如果匹配到跳转下一页 }else{ //没有匹配到的话,跳转404 next({path:'/404'}) }