index.js 690 B

123456789101112131415161718192021222324252627
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import { constantRouterMap } from '@/config/router.config'
  4. try {
  5. const originalPush = Router.prototype.push
  6. Router.prototype.push = function push(location) {
  7. return originalPush.call(this, location).catch(err => err)
  8. }
  9. } catch (e) {
  10. }
  11. Vue.use(Router)
  12. // const originalPush = Router.prototype.push;
  13. // Router.prototype.push = function push(location) {
  14. // if(location.name){
  15. // return originalPush.call(this, location).catch(err => err)
  16. // }
  17. // }
  18. export default new Router({
  19. mode: 'history',
  20. base: process.env.BASE_URL,
  21. scrollBehavior: () => ({ y: 0 }),
  22. routes: constantRouterMap
  23. })