vue 路由跳转原路由报错

181 阅读1分钟

在src/router/index.js中添加以下配置

import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
//解决路由跳转原路由或者刷新出错
const originalReplace = Router.prototype.replace;
Router.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch(err => err);
};
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}