const Router = VueRouter; const routes = [ //默认跳转到登录页 { path: "/", redirect: "/login" }, //默认跳转到登录页 { path: '/login', component: () => import('@/views/login/index'), hidden: true }, { path: '/home', component: () => import('@/layout/index'), redirect: '/paddy', children: [ { path: 'paddy', component: () => import('@/views/paddy/index'), name: 'paddy', // alwaysShow: true, meta: { title: '稻田', noCache: true, breadcrumb: true } }, { path: 'product', component: () => import('@/views/product/index'), name: 'product', // alwaysShow: true, meta: { title: '产品', noCache: true, breadcrumb: true } }, { path: 'my', component: () => import('@/views/my/index'), name: 'my', // alwaysShow: true, meta: { title: '我的', noCache: true, breadcrumb: true } }, ] }, { path: '/orderRes', component: () => import('@/views/order/orderRes'), hidden: true }, { path: '/liveD', component: () => import('@/views/live/liveD'), hidden: true }, { path: '/address', component: () => import('@/views/address/index'), hidden: true }, { path: '/addressView', component: () => import('@/views/address/view'), hidden: true }, { path: '/live', component: () => import('@/views/live/index'), hidden: true }, { path: '/order', component: () => import('@/views/order/index'), hidden: true }, { path: '/oDetail', component: () => import('@/views/order/detail'), hidden: true }, { path: '/aboutUs', component: () => import('@/views/aboutUs/index'), hidden: true }, { path: '/referMenu', component: () => import('@/views/referMenu/index'), hidden: true }, { path: '/introduce', component: () => import('@/views/introduce/index'), hidden: true }, { path: '/goods', component: () => import('@/views/goods/index'), hidden: true }, ]; console.log(process.env.BASE_URL); const router = new Router({ mode: "hash", base: process.env.BASE_URL, scrollBehavior: () => ({ y: 0 }), routes }); // 重写路由的push方法,主要是为了解决同一个路由路径重复点击报错 const routerPush = Router.prototype.push; Router.prototype.push = function push(location) { return routerPush.call(this, location).catch(error => error); }; Vue.use(Router); export default router;