解决Vue-Router升级导致的Uncaught(in promise) navigation guard问题

在new VueRouter后边加上以下代码

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
    if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
    return originalPush.call(this, location).catch(err => err)
}
posted on 2021-05-11 10:06  柳暗花明8963  阅读(1539)  评论(0编辑  收藏  举报