vue报错 NavigationDuplicated: Avoided redundant navigation to current location:

在项目中点击关于本页面的路由时会报这个错误

这个错误的意思是NavigationDuplicated:避免了对当前位置的冗余导航

简单点来说就是 你这小子已经在我这里了 怎么还在叫老子

如何解决这个问题?

你可以在router的配置文件index中 写入以下代码

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.js,javascript,前端)