vue-routerV3.1版本報錯:message: "Navigating to current location ("/home") is not allowed",


出現這個錯誤的原因是,在路由跳轉的時候兩次push的path地址相同

解決方法兩種:

1.切換版本回3.0版本

2.在你引了vue-router的js文件里加上如下代碼即可

import VueRouter from "vue-router";
// 解決兩次訪問相同路由地址報錯
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM