我正在使用react-router进行路由,我使用hashHistory选项,以便我可以从浏览器刷新页面或指定我现有路线的URL并登陆到右侧页面.
它工作正常,但我在网址中看到这样的哈希:
http://localhost/#/login?_k=ya6z6i
它工作正常,但我在网址中看到这样的哈希:
http://localhost/#/login?_k=ya6z6i
这是我的路由配置:
ReactDOM.render(( <Router history={hashHistory}> <Route path='/' component={MasterPage}> <IndexRoute component={LoginPage} /> <Route path='/search' component={SearchPage} /> <Route path='/login' component={LoginPage} /> <Route path='/payment' component={PaymentPage} /> </Route> </Router>),document.getElementById('app-container'));
您是否尝试过browserHistory选项?您还可以从浏览器刷新页面或指定其中一条现有路线的URL并登陆右侧页面.
原文链接:https://www.f2er.com/react/301262.htmlimport { Router,Route,browserHistory } from 'react-router'; ReactDOM.render(( <Router history={browserHistory}> <Route path='/' component={MasterPage}> <IndexRoute component={LoginPage} /> <Route path='/search' component={SearchPage} /> <Route path='/login' component={LoginPage} /> <Route path='/payment' component={PaymentPage} /> </Route> </Router>),document.getElementById('app-container'));
而且考虑到react-router github doc,hashHistory不能用于生产.
https://github.com/ReactTraining/react-router/blob/master/docs/guides/Histories.md#browserhistory
我应该使用hashHistory吗?
@H_403_19@Hash history works without configuring your server,so if you’re just getting started,go ahead and use it. But,we don’t recommend using it in production,every web app should aspire to use browserHistory