vue报错NavigationDuplicated: Avoided redundant navigation to current location: “/“.

2022-07-28,,,,

在写导航切换时点击会有以下报错

这个报错是是路由中点击路径重复 ,也有可能是安装的vue-router还是之前出错的那个版本,在项目目录下运行 npm i vue-router@3.0 -S 即可。
解决方法1:在 main.js里添加一段代码。
代码如下:

import Router from 'vue-router'
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)}

解决方法2:安装

 npm i vue-router@3.0 -S 
 //npm 安装慢 要是有安装淘宝镜像 cnpm安装也可以

本文地址:https://blog.csdn.net/Rick_and_mode/article/details/109363706

《vue报错NavigationDuplicated: Avoided redundant navigation to current location: “/“..doc》

下载本文的Word格式文档,以方便收藏与打印。