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

  • Solve the problem of Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation when passing parameters in Vue routing  .
  • 报错内容:Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/search/111".
  • Description of the problem: When the navigation is repeatedly clicked, the console reports an error

Browser error screenshot:

 Solution: Add the following code to the src/router/index.js configuration file

// 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)
}

 

Guess you like

Origin blog.csdn.net/m0_64351096/article/details/127051943