hejianhao
2025-01-08 d8f03af7716a636ca48b87da29bcd6ccb2e6b8c6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import Vue from 'vue'
import Router from 'vue-router'
import routers from './routers';
 
const changePush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return changePush.call(this, location).catch((err) => err);
};
Vue.use(Router);
 
 
const createRouter = () => new Router({
  mode: 'hash', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: routers
})
 
const router = createRouter()
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}
 
export default router