vue报错vue-router.esm.js?8c4f:2062 Uncaught (in promise) Error: Avoided redundant navigation to curren

    技术2022-07-11  89

    在写导航切换时点击会有以下报错 这个报错是是路由中点击路径重复 ,也有可能是安装的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安装也可以
    Processed: 0.012, SQL: 12