vue中路由双击bug的解决 以及地址栏中#去除的配置

Villagers

关注

阅读 88

2022-02-13

双击跳转路由时,会报错,可以给VueRouter设置相关的重置方法解决问题,找到router/index.js添加下面两行代码

在这里插入代码片
//解决 用this.routes.push 跳转时报错问题
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
    //吧地址栏中的#去掉
    mode:'history',
    routes
})

精彩评论(0)

0 0 举报