在 Router / index.js (路由配置文件) 中:
/* 1. 备份push方法
*/
let originPush = VueRouter.prototype.push
console.log(originPush);
/* 2. 重写push方法
*/
/*
location:跳转地址,传递的参数
resolve:成功时回调
reject:失败时回调
*/
VueRouter.prototype.push = function (location, resolve, reject) {
if (resolve && reject) {
originPush.call(this, location, resolve, reject)
} else {
originPush.call(this, location, () => {}, () => {})
}
}
最后
以上就是开心导师最近收集整理的关于解决 this.$router.push 多次执行时报 navigationDuplicated 错误的全部内容,更多相关解决内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复