[Solved] Vue route jumps to the same page many times error: Navigationduplicated

Vue route jumps to the same page and reports an error many times. Navigationduplicated

The error report does not affect the program operation, but it is annoying to be popular. It needs to be solved.
the reason for the error report is this$ router. Push returns promise
just like

function push(){
	return new  Promise((resolve,reject)=>{
	})
}

Solution 1: capture success value and error value (treat symptoms but not root causes)

this.$router.push({
          name: "project",
          params: { projectPattern: this.projectPattern },
        },()=>{},()=>{ });

Solution 2: Rewrite push
and use it the same as before

this.$router.push({
          name: "project",
          params: { projectPattern: this.projectPattern },
        });

In router/index JS file, write a process by judging whether there are resolve and reject incoming values

let originPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location, resolve, reject) {
  if (resolve && reject) {
    originPush.call(this,location,resolve,reject)
  }else{
    originPush.call(this,location,()=>{},()=>{})
  }
}```

Read More: