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

posted @ 2018-10-29 02:24  zhourongcode  阅读(4102)  评论(0编辑  收藏  举报