您的位置:首页 > Web前端 > Vue.js

vue router Uncaught (in promise)

2020-03-27 03:51 656 查看

原因: 没有使用catch捕获方法

解决方法: 重写 Router 原型链上的 push、replace 方法

import Router from 'vue-router'

const originalPush = Router.prototype.push
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)
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐