vue-router.esm.js?Uncaught(inpromise)NavigationDuplicated{_name:“NavigationDuplicated报错内容

原创
小哥 3年前 (2022-11-14) 阅读数 11 #大杂烩

多次重复单击跳转路线按钮以报告错误

只需在router下的index.js写入以下代码

const originalReplace = Router.prototype.replace;
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};
Router.prototype.replace = function replace(location, onResolve, onReject) {
  if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject);
  return originalReplace.call(this, location).catch((err) => err);

如果你写完后使用它replace和push反复点击也不会导致红色爆炸

版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除