index.js 849 B

1234567891011121314151617181920212223242526
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import { constantRouterMap } from './router.config.js'
  4. // 解决vue router 升级到3.1.x 后,重复点击导航时NavigationDuplicated
  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. const createRouter = () =>
  12. new Router({
  13. // mode: 'history', // 如果你是 history模式 需要配置vue.config.js publicPath
  14. // base: process.env.BASE_URL,
  15. // base: '/home/nginx/www/hsay/h5',
  16. scrollBehavior: () => ({ y: 0 }),
  17. routes: constantRouterMap
  18. })
  19. const router = createRouter()
  20. console.log(router)
  21. export default router