Vue Avoided redundant navigation to current location Error


这个报错的根源就是vue-router组件,错误内容翻译一下是: Avoided redundant navigation to current location === 避免冗余导航到当前位置

这个问题的解决方案就是屏蔽它,就是重写vue-router的push方法,不影响正常使用

在 Vue.use(VueRouter的时候),前面加上这一句即可

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

主要的作用就是把err给屏蔽了,不进行输出了,页面看不到这个错误,但是不影响使用

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM