4 个回答

用 BrowserRouter from 'react-router-dom'

https://react-guide.github.io...

import { Router, Route, hashHistory } from 'react-router';

render((
  <Router history={hashHistory}>
    <Route path="/" component={App}/>
  </Router>
), document.getElementById('app'));

<Redirect from='*' to='/index' />作为Router的最后一个子元素,这样所有的没有匹配路径都会默认为/index这个路径

去路由器配置一下即可,建议看一下api文档

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题