美文网首页
解决路由跳转报错Navigation cancelled fro

解决路由跳转报错Navigation cancelled fro

作者: 袁猿源 | 来源:发表于2021-01-11 14:46 被阅读0次

import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
// 解决报错
const originalPush = Router.prototype.push
const originalReplace = Router.prototype.replace
// 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)
}
// replace
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)
}

相关文章

网友评论

      本文标题:解决路由跳转报错Navigation cancelled fro

      本文链接:https://www.haomeiwen.com/subject/vqddaktx.html