import Vue from 'vue'; import VueRouter from 'vue-router'; import layout from '@/layout/index.vue'; const originalPush = VueRouter.prototype.push; VueRouter.prototype.push = function push(location) { return originalPush.call(this, location).catch((err) => err); }; Vue.use(VueRouter); const router = new VueRouter({ mode: 'history', // scrollBehavior(to, from, savedPosition) { // if (savedPosition) { // return savedPosition; // } else { // return { x: 0, y: 0 }; // } // }, base: '/agent/', routes: [ { path: '/', component: layout, redirect: '/home', children: [ { path: '/home', name: 'home', component: () => import('@/views/home/index.vue'), meta: { title: '首页', }, }, ], }, { path: '/agentList', component: layout, redirect: '/agentList', children: [ { path: '/agentList', name: 'agentList', component: () => import('@/views/agentList/index.vue'), meta: { title: '经销商拜访', }, }, { path: '/visitPage', name: 'visitPage', component: () => import('@/views/agentList/visitPage.vue'), meta: { title: '拜访详情', }, }, { path: '/visitTask', name: 'visitTask', component: () => import('@/views/agentList/visitTask.vue'), meta: { title: '拜访任务', }, }, { path: '/visitHistory', name: 'visitHistory', component: () => import('@/views/agentList/visitHistory.vue'), meta: { title: '拜访历史', }, }, { path: '/visitHistoryDetail', name: 'visitHistoryDetail', component: () => import('@/views/agentList/visitHistoryDetail.vue'), meta: { title: '拜访历史详情', }, }, { path: '/visitAbnormal', name: 'visitAbnormal', component: () => import('@/views/agentList/visitAbnormal.vue'), meta: { title: '拜访异常', }, }, { path: '/visitedTaskDetail', name: 'visitedTaskDetail', component: () => import('@/views/agentList/visitedTaskDetail.vue'), meta: { title: '拜访任务详情', }, }, ], }, { path: '/info', component: layout, redirect: '/info', children: [ { path: '/info', name: 'info', component: () => import('@/views/info/index.vue'), meta: { title: '我的', }, }, { path: '/infoHistorVisit', name: 'infoHistorVisit', component: () => import('@/views/info/infoHistorVisit.vue'), meta: { title: '历史拜访', }, }, ], }, { path: '/err', name: 'err', component: () => import('@/views/err.vue'), meta: { title: '404', }, }, { path: '/login', name: 'login', component: () => import('@/views/login.vue'), meta: { title: '登录', }, }, ], }); export default router;