使用this.$router.push()进行跳转时多次点击报错。

1.跳转时添加回调函数

    gotoLink(item){
      // this.$router.push(item.url)
      this.$router.push(item.url,()=>{}, ()=>{})
    },

2.修改VueRouter原型对象上的push方法


// 获取原型对象push函数
const VueRouterPush = VueRouter.prototype.push
// 修改原型对象中的push函数
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

在router-> index.js中添加。

Logo

一站式 AI 云服务平台

更多推荐