解决message: "Navigating to current location ("/homePage") is not allowed",警告的问题

一.现象

进行书写项目时,出现一个警告message: “Navigating to current location (”/home") is not allowed",
且在ie11中运行项目,一样出现此警告,且涉及到的路由组件页面将不会刷新出来,呈现一片空白
"Navigating to current location ("/home") is not allowed"vue

二.缘由

网上大佬彷佛都说是由于vue-router3.1版本的问题
不过vue-router 官方在 2019-08-06 推出的 vue-router@3.1.1 彷佛已经修复了此 bug
即安装的@3.1.1以上的版本均可以解决此问题web

三.解决方案

1.切换版本回3.0版本
2.在路由的index.js文件中书写如下代码vue-router

import VueRouter from "vue-router";
//此VueRouter是本身自定义引入暴露出来的,便是自定义的,如下的VueRouter一样是这样
// 解决两次访问相同路由地址报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}