vue項目路由出現message: "Navigating to current location (XXX) is not allowed"的問題

在這裏插入圖片描述

出錯原因路由中添加了相同的路由

解決方法

src/router/index.js中重寫push方法

/*重寫router.push方法*/
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章