React Router v4 中的 hashHistory 在哪里?
Where's hashHistory in React Router v4?
我正在尝试为我的 React 应用程序使用路由器。我尝试了一段时间前一直在使用的东西,但似乎无法让它继续运行。 hashHistory
在 React Router v4 中已经 removed/reformatted 了吗?
<Router history={hashHistory}>
<Route path='/' component={MainContainer} />
</Router>
使用 HashRouter
。他们摆脱了 browserHistory
和 hashHistory
等个人历史记录,而是在 React Router v4 中分别用 BrowserRouter
和 HashRouter
组件替换它们:
import { HashRouter } from 'react-router-dom';
<HashRouter>
…
</HashRouter>
请注意 HashRouter
来自 react-router-dom
,而不是核心 react-router
包 .
我正在尝试为我的 React 应用程序使用路由器。我尝试了一段时间前一直在使用的东西,但似乎无法让它继续运行。 hashHistory
在 React Router v4 中已经 removed/reformatted 了吗?
<Router history={hashHistory}>
<Route path='/' component={MainContainer} />
</Router>
使用 HashRouter
。他们摆脱了 browserHistory
和 hashHistory
等个人历史记录,而是在 React Router v4 中分别用 BrowserRouter
和 HashRouter
组件替换它们:
import { HashRouter } from 'react-router-dom';
<HashRouter>
…
</HashRouter>
请注意 HashRouter
来自 react-router-dom
,而不是核心 react-router
包 .