In Vue project, when repeatedly clicking route, the console will report an error:
Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to crrent location: “/home”
The online solution is to add the following code in the router folder:
// src/router/index.js
const VueRouterPush = Router.prototype.push
Router.prototype.push = function push (to) {
return VueRouterPush.call(this, to).catch(err => err)
}
However, errors are still reported in the compilation process.
Finally, a solution is found
itemClick() {
// Original code: this.$router.replace(this.path)
// Add .catch(err=>err) after the code for route jumping
// either the replace or push method will work
this.$router.replace(this.path).catch(err=>err)
}
Read More:
- Vue Error: Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location
- VueUncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: “/
- [Solved] Uncaught (in promise) Error: Avoided redundant navigation to current location:
- [Solved] Vue console error: navigationduplicated: avoided redundant navigation to current location
- Vue elementui: solution for error: avoided redundant navigation to current location: “/xxx”
- [Solved] Vue Error: Avoided redundant navigation to current location:/xxxx
- Vue: How to Solve error avoided redundant navigation to current location: “/xxx”
- How to solve Uncaught (in promise) error in VUE?
- How to Solve Uncaught (in promise) Error (Two Solutions)
- [Solved] Vue route jumps to the same page many times error: Navigationduplicated
- [Solved] Uncaught (in promise) DOMException: Failed to load because no supported source was found.
- [Solved] Echarts Error: Uncaught (in promise) Error: Initialize failed: invalid dom.
- [Solved] Uncaught (in promise) TypeError: XXX.a is not a constructor
- [Solved] Vue-router Error: Navigation cancelled from “/course“ to “/user“ with a new navigation.
- ArcGIS API for JavaScript Error Uncaught(in promise): TypeError: xxx is not a constructor
- [Solved] echarts Draw Errror: echarts-d9fd185e.js:31447 Uncaught (in promise) Error: Initialize failed: invalid dom.
- [Solved] Turf.js error: uncaught (in promise) error: the solution of invalid unit
- Vue solves the problem of repeated click navigation route error
- [Solved] vue-roter 4 Error: Error: Invalid route component/Uncaught (in promise) Error: Invalid route component
- request.js?b775:101 Uncaught (in promise) Error: Failed to convert value of type ‘java.lang.String’ to required type ‘java.lang.Long’;