全局解决Vue路由重复导航报错问题,在创建 router 实例时添加错误处理:
进入index.js文件
![]()
添加以下代码即可:
//重复跳转报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => {
if (err.name !== 'NavigationDuplicated') {
throw err
}
})
}

570

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



