import Vue from 'vue' import VueRouter from 'vue-router' Vue.use(VueRouter) const originalPush = VueRouter.prototype.push VueRouter.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err) } const routes = [ { path: "/", component: () => import('@/views/index'), }, // { // path:'/login', // name:'Login', // meta: { // title: '系统登录' // }, // component: () => import("@/views/login/index.vue") // }, { path: "", component: () => import('@/views/layout/index.vue'), children: [ { path: '/home', name: 'Home', meta: { // title: '首页', sign: 'home', belong: 'home' }, component: () => import('@/views/home/index.vue'), }, ] } ] const router = new VueRouter({ mode: 'history', base: '/', routes }) router.beforeEach((to, from, next) => { if (to.meta.title) { document.title = to.meta.title; } next(); }) router.afterEach((to, from) => { }); export default router