健康同学微信公众号h5项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
123456789101112131415161718192021222324252627282930
  1. import Vue from 'vue';
  2. import Router from 'vue-router';
  3. import { constantRouterMap } from './router.config.js';
  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. const createRouter = () =>
  12. new Router({
  13. // mode: 'history', // 如果你是 history模式 需要配置vue.config.js publicPath
  14. // base: process.env.BASE_URL,
  15. scrollBehavior: () => ({ y: 0 }),
  16. routes: constantRouterMap
  17. });
  18. const router = createRouter();
  19. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  20. export function resetRouter() {
  21. const newRouter = createRouter();
  22. router.matcher = newRouter.matcher; // reset router
  23. }
  24. // TODO 增加路由拦截
  25. export default router;