报错如下:

解决方法:
在路由器router里面的index.js里面加上下面这段代码就没事了
const originalPush = Router.prototype.push
const originalReplace = Router.prototype.replace
Router.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)
}
Router.prototype.replace = function push(location, onResolve, onReject) {
if (onResolve || onReject) {
return originalReplace.call(this, location, onResolve, onReject)
}
return originalReplace.call(this, location).catch(err => err)
}
本文介绍了如何解决JavaScript中遇到的'Uncaught (in promise) Error: Navigation cancelled from “/...“ to “/...“ with a new navigation.'错误。通过在路由配置router的index.js文件中添加特定代码,可以成功解决这个问题。
8369

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



