Solve the problem of vue jumping to the same route and reporting an error

In vue, if you jump to the same page route, although it will not affect the function, it will report an error

Reason: The push of the route will add a record to the history stack, and jump to the same route page at the same time, which will cause a repeated addition, resulting in an error on the page

Solution: rewrite vue's routing jump push in router's index.js

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err);
}

Guess you like

Origin blog.csdn.net/hjdjhh/article/details/122806218