按需加载路由可避免不必要的路由加载
新建router文件下movie文件
export default { path:'/movie', redirect:'/movie/nowPlaying', component:()=>import('@/view/movie'),//按需加载路由只在view/movie中可使用
children:[ {path: 'citylist', component:()=>import('@/components/movieIndex/citylist') },
{path: 'willPlaying', component:()=>import('@/components/movieIndex/willPlaying')},
{path: 'nowPlaying', component:()=>import('@/components/movieIndex/nowPlaying')}, ] }
在router文件下的index中引用
import movieRouter from "../router/movie"//引入上面所加的文件 Vue.use(Router) export default new Router({ routes: [ movieRouter,//进行注册 ] })