Vue重复跳转同一个路由报错

346 阅读1分钟

跳转同一个路由会报错?

  • 路由规定不能跳转到同一个路由地址

  • 解决:在配置路由的文件中(src/touter/index.js)添加以下代码

// 解决重复跳转同一个路由报错问题
//VueRouter:这个是导入路由使用的变量
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}