message appears resolve vue route project: "Navigating to current location (XXX) is not allowed" problem

Reason: add the same route in the route.
Solution:
Rewrite push method of routing

In src / router / index.js which import Router from 'vue-router' by writing to the following method

/**
 * 重写路由的push方法
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}

  

Guess you like

Origin www.cnblogs.com/lezuw/p/11718087.html