提交者
Gitee
!712 修复路由跳转被阻止时vue-router内部产生报错信息问题
Merge pull request !712 from 爱吃猫的鱼/master
正在显示
1 个修改的文件
包含
6 行增加
和
0 行删除
| @@ -166,9 +166,15 @@ export const dynamicRoutes = [ | @@ -166,9 +166,15 @@ export const dynamicRoutes = [ | ||
| 166 | 166 | ||
| 167 | // 防止连续点击多次路由报错 | 167 | // 防止连续点击多次路由报错 |
| 168 | let routerPush = Router.prototype.push; | 168 | let routerPush = Router.prototype.push; |
| 169 | +let routerReplace = Router.prototype.replace; | ||
| 170 | +// push | ||
| 169 | Router.prototype.push = function push(location) { | 171 | Router.prototype.push = function push(location) { |
| 170 | return routerPush.call(this, location).catch(err => err) | 172 | return routerPush.call(this, location).catch(err => err) |
| 171 | } | 173 | } |
| 174 | +// replace | ||
| 175 | +Router.prototype.replace = function push(location) { | ||
| 176 | + return routerReplace.call(this, location).catch(err => err) | ||
| 177 | +} | ||
| 172 | 178 | ||
| 173 | export default new Router({ | 179 | export default new Router({ |
| 174 | mode: 'history', // 去掉url中的# | 180 | mode: 'history', // 去掉url中的# |
-
请 注册 或 登录 后发表评论