vue3.x 重复点击路由报错

在这里插入图片描述

这个报错是重复路由引起的。

在 route 文件夹下的 index.js 中修改

需要给VueRouter里面自己重写 push 和 replace 方法
在这里插入图片描述

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    
    
  return originalPush.call(this, location).catch(err => err)
}

const originalReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(location) {
    
    
  return originalReplace.call(this, location).catch(err => err);
};

猜你喜欢

转载自blog.csdn.net/weixin_45773503/article/details/113784748
今日推荐