Avoided redundant navigation to current location

Time:2021-2-18

This error is encountered in the Vue project, which does not affect the function, but the console will report this error when pushing:

vue-router.esm.js?fe87:1958 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/Home".

After searching online for a long time, almost all of them said that there was a problem with the version of Vue router, either reloading the lower version, or using the main.js Add the following code:
const originalPush = Router.prototype.push Router.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err) }

But I tried for a long time and it’s useless. My console reported a syntax error that push doesn’t exist. The compilation can’t pass. Maybe only I can’t use this solution.


This solution:

Because there is only one push home page in my project, I just need to catch the exception of push (the same with replace).

//Set home page default display
        this.$router.push('/Home').catch(err=>err);

Recommended Today

Analysis of super comprehensive MySQL statement locking (Part 1)

A series of articles: Analysis of super comprehensive MySQL statement locking (Part 1) Analysis of super comprehensive MySQL statement locking (Part 2) Analysis of super comprehensive MySQL statement locking (Part 2) Preparation in advance Build a system to store heroes of the Three KingdomsheroTable: CREATE TABLE hero ( number INT, name VARCHAR(100), country varchar(100), PRIMARY […]