index.js 574 B

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