Vue使用路由报错
报错:
Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/user/zhangsan".
解决办法:
看自己是选用了什么样的跳转方式:两种跳转方式push和replace
push:
Vue.use(Router)
const originalPush1 = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush1.call(this, location).catch(err => err)
}
replace:
Vue.use(Router)
const originalReplace2 = Router.prototype.replace;
Router.prototype.replace = function replace(location) {
return originalReplace2.call(this, location).catch(err => err);
};