react-router4中location.action的改变

react-router4中history.push or history.replace的location.action都为'REPLACE'。

  1. history.go(-1)
    clipboard.png
  2. history.push
    clipboard.png
  3. history.replace
    clipboard.png

路由设置为:

<Route exact path="/A/a"
    render={() => (<Redirect to="/A/a/aa/aaa"/>)}/>

直接history.push(‘/A/a/aa/aaa’),location.action为‘POP’,但如果history.push('/A/a'),location.action则会为‘REPLACE’

这是react-router4的改变吗?那么如果我要如何区分history.go(-1)和history.push('/A/a/aa/aaa')呢??

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