vue路由解决Uncaught (in promise) Error: Avoided redundant navigation to current location: “/home/news“.
原创
©著作权归作者所有:来自51CTO博客作者wx637f0ba1ddc42的原创作品,请联系作者获取转载授权,否则将追究法律责任
在添加如下步骤后报错,但是不影响使用:
activated(){
this.$router.push(this.path);
},
解决办法:
在router文件夹下的index.js中加入如下代码,错误消失
import Vue from 'vue'
import VueRouter from 'vue-router'
//import HelloWorld from '@/components/HelloWorld'
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}