vue-router——message: "Navigating to current location (XXX) is not allowed"

解決方法:

  • 法一:重寫規則
import VueRouter from "vue-router";

const [routerPush, routerReplace] = [VueRouter.prototype.push, VueRouter.prototype.replace];
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error);
};
VueRouter.prototype.replace = function replace(location) {
  return routerReplace.call(this, location).catch(error => error);
};
  • 法二:降級處理(3.1 以下)
cnpm i [email protected] -S
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章