// 多次点击同一路由报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
return originalPush.call(this, location).catch(err => err)
}
把这个放在路由router的页面
本文介绍了一种解决Vue Router中多次点击同一路由导致错误的方法。通过覆盖VueRouter的push方法,实现错误捕获并阻止其传播,确保了用户体验不受影响。
// 多次点击同一路由报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
return originalPush.call(this, location).catch(err => err)
}
把这个放在路由router的页面
5986

被折叠的 条评论
为什么被折叠?