React 項目使用 React-router-dom 4.0 以上版本時使用 HashRouter 怎么控制 history


Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack

解決方案是安裝使用 history 模塊

import createBrowserHistory from "history/createBrowserHistory";
const customHistory = createBrowserHistory();

<Router history  = {customHistory} />

注意引入的 HashRouter 改變成 Router


免責聲明!

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



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