inleft
2022-02-09 9bcb19959eeb9da9bde2561e7278f6d0a55eb151
commit | author | age
9bcb19 1 import Vue from 'vue'
I 2 import Router from 'vue-router'
3 import { constantRouterMap } from '@/config/router.config'
4
5 // hack router push callback
6 const originalPush = Router.prototype.push
7 Router.prototype.push = function push (location, onResolve, onReject) {
8   if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
9   return originalPush.call(this, location).catch(err => err)
10 }
11
12 Vue.use(Router)
13
14 export default new Router({
15   mode: 'history',
16   base: process.env.BASE_URL,
17   scrollBehavior: () => ({ y: 0 }),
18   routes: constantRouterMap
19 })