vue重复点击路由报错

vue再连续多次点击同一路由的时候,会报以下错误:

Avoided redundant navigation to current location: '/xxx

vue重复点击路由报错_第1张图片

可以通过在main.js 或路由配置文件(index.js)中重写push的方法,解决该问题


import VueRouter from 'vue-router'

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

你可能感兴趣的:(VUE实战,vue.js,javascript,前端)