After Vue router is upgraded to 3.1. X, when repeatedly clicking the navigation, the console will report an error. Although it does not affect the use of the function, it can not be ignored.
Error information
Cause of error
After Vue router ≥ v3.1, the callback form is changed to promise API, and promise is returned. If no error is caught, the console will always display the warning as shown in the figure above.
How to Solve This Error
[method 1] reduce the version
npm i [email protected] -S
[method 2] add the following code in the router folder
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
return routerPush.call(this, location).catch(error=> error)
}
[method 3] capture exception
// router.push error
this.$router.push(route).catch(err => {
console.log('outpur error',err)
})
[method 4] complete the third parameter of router
// Completing the third argument of router.push()
this.$router.push(route, () => {}, (e) => {
console.log('output error',e)
})
Read More:
- Vue solves the problem of repeated click navigation route error
- How to Solve Vue route jump repeated clicks Error
- [Solved] Vue console error: navigationduplicated: avoided redundant navigation to current location
- [Solved] Vue route jumps to the same page many times error: Navigationduplicated
- Vue: How to Solve error avoided redundant navigation to current location: “/xxx”
- Jest Vue $route error [How to Modify]
- [Solved] Vue Route Error: Uncaught TypeError: (0 , vue__WEBPACK_IMPORTED_MODULE_42__.defineComponent) is not a function
- vue.config.js build Package UglifyJsPlugin to clear console and print console.log Error: `warnings` is not a supported option
- Vue elementui: solution for error: avoided redundant navigation to current location: “/xxx”
- Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to crrent location: “/home“
- Vue Error: Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location
- [Solved] vue-roter 4 Error: Error: Invalid route component/Uncaught (in promise) Error: Invalid route component
- How to solve Uncaught (in promise) error in VUE?
- Solving routing errors by rewriting Vue push method
- [Solved] Uncaught (in promise) Error: Avoided redundant navigation to current location:
- [Solved] Vue Error: Avoided redundant navigation to current location:/xxxx
- VueUncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: “/
- How to open a page in a new window by Vue router
- How to Solve “Vue is not defined” Error
- Use of $watch in Vue (solve rangeerror: maximum call stack size exceeded)