Uncaught (in promise) NavigationDuplicated [How to Solve]

The reason is: Vue router is in 3 After the X version, put this$ router. The replace () method is changed to promise. If there is no callback function, the error message will be displayed globally


1. Reduce Vue router version to 3.0 Below 7

npm install [email protected] -s

2. Add a callback for this.$router.replace() method

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)

Similar Posts: