路由跳转问题
Vue路由的跳转的四种方式
问题描述:在使用this.$router.push
和this.$router.replace
的时候发生了报错,且不会跳转到对应的页面, 控制台会出现这个报错,但是不影响正常使用,但是又错误还是要解决的
解决这$route
跳转路由问题
报错信息:Avoided redundant navigation to current location
代码:
// 这样控制台就能避免路由跳转带来的错误
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function(location) {
return originalPush.call(this, location).catch(err => err)
}