Skip to content

Commit c410125

Browse files
authored
1 parent bedbd3c commit c410125

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

web/src/router/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import Router from 'vue-router'
33

44
Vue.use(Router)
55

6+
//获取原型对象上的push函数
7+
const originalPush = Router.prototype.push
8+
//修改原型对象中的push方法
9+
Router.prototype.push = function push(location) {
10+
return originalPush.call(this, location).catch(err => err)
11+
}
12+
613
const baseRouters = [{
714
path: '/',
815
redirect: '/login'
@@ -23,4 +30,4 @@ const createRouter = () => new Router({
2330

2431
const router = createRouter()
2532

26-
export default router
33+
export default router

0 commit comments

Comments
 (0)