import Vue from 'vue' import Router from 'vue-router' Vue.use(Router) export default new Router({ routes: [ { path: '/index', name: 'index', // 路由级代码拆分,这将为此路由生成单独的块,当路线被访问时延迟加载 (路由懒加载) component: () => import('./views/index/index'), meta: { title: '首页', requireAuth: true //不需要验证登录 } }, { path: '/index1', name: 'index1', // 路由级代码拆分,这将为此路由生成单独的块,当路线被访问时延迟加载 (路由懒加载) component: () => import('./views/index/index1'), meta: { title: '首页1', requireAuth: true //不需要验证登录 } }, { path: '/index2', name: 'index2', // 路由级代码拆分,这将为此路由生成单独的块,当路线被访问时延迟加载 (路由懒加载) component: () => import('./views/index/index2'), meta: { title: '首页2', requireAuth: true //不需要验证登录 } }, { path: '/index3', name: 'index3', // 路由级代码拆分,这将为此路由生成单独的块,当路线被访问时延迟加载 (路由懒加载) component: () => import('./views/index/index3'), meta: { title: '首页3', requireAuth: true //不需要验证登录 } }, { path: '/index4', name: 'index4', // 路由级代码拆分,这将为此路由生成单独的块,当路线被访问时延迟加载 (路由懒加载) component: () => import('./views/index/index4'), meta: { title: '首页4', requireAuth: true //不需要验证登录 } }, { path: '/index5', name: 'index5', // 路由级代码拆分,这将为此路由生成单独的块,当路线被访问时延迟加载 (路由懒加载) component: () => import('./views/index/index5'), meta: { title: '首页5', requireAuth: true //不需要验证登录 } }, { path: '/login', name: 'login', component: () => import('./views/login/login'), meta: { title: '登录', requireAuth: true //不需要验证登录 } }, { path: '/', name: 'home', component: () => import('./views/home'), redirect: 'index', meta: { }, children: [ { path: 'index', name: 'Index', component: () => import('./views/index/index'), meta: { title: '首页', }, } ] }, ], linkActiveClass: 'active', //当前完全路由的样式 一般有子路由时用 scrollBehavior(to, from, savedPosition) { //to 要跳转到的路由 from从哪个路由调到哪个路由 savedPosition 当前滚动条的位置 if (savedPosition) { return savedPosition } else { return { x: 0, y: 0 } } }, })