在router.js中加入以下代码就可以

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

如果你的改了push还是没有生效,修改路由replace方法,阻止重复点击报错

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

 

Logo

前往低代码交流专区

更多推荐