Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location报错

Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location报错

  • 解决 Vue 路由传递参数时,出现 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation 问题 .
  • 报错内容:Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/search/111".
  • 问题描述:重复点击导航时,控制台报错

报错

解决方法

  • src/router/index.js 配置文件中添加以下代码
// src/router/index.js
import Vue from 'vue'
import VueRouter  from 'vue-router'
Vue.use(VueRouter)
 
//添加以下代码
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

posted @ 2022-11-10 15:39  itwetouch  阅读(359)  评论(0编辑  收藏  举报