为什么我的url输入每次都会自动添加一个#

用的是react-router4,每一次手动输入url进行跳转都会自动添加一个#

比如 我输入 localhost:8000/index => localhost:8000/index#/ 变成这样了

路由代码是

function RouterConfig({ history }) {
  return(
  <Router history={history}>
     <Switch>
      <Route exact path="" component={lsPage}/>
      <Route exact path="/index" component={layout} />
      </Switch>
  </Router>
  )
} 
export default RouterConfig;
阅读 7.5k
3 个回答

您是不是使用的hashHistory路由。
使用hashHistory,浏览器的url就是这样的:localhost:8000/index#/
而使用browserHistory,浏览器的url是这样的:localhost:8000/index

希望我的回答能帮助到您^_^

新手上路,请多包涵

你是怎么解决的呀,我也遇到了

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