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