在引入vue-router的js文件里加上如下代码:

//push
const VueRouterPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch(err => err);
};

//replace
const VueRouterReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(to) {
  return VueRouterReplace.call(this, to).catch(err => err);
};

相关文章:

  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2021-10-20
  • 2021-08-21
  • 2021-06-21
  • 2021-10-29
猜你喜欢
  • 2022-12-23
  • 2023-04-04
  • 2022-12-23
  • 2021-11-01
  • 2021-11-23
  • 2021-11-02
  • 2022-12-23
相关资源
相似解决方案