是否可以从ReactRouter.browserHistory
获取前一个路径数和路径值?
答案 0 :(得分:1)
其实你做不到。
但您可以尝试在browserHistory
状态下存储列表,并在重定向时在其中推送新路径。
let history = this.props.location.state.history;
history.push(this.props.location.pathname)
browserHistory.push({
pathname: '/yourpath',
state: { history: history }
})
通过这种方式,您应该在this.props.location.state.history
答案 1 :(得分:0)
只有我发现重定向到上一页是
this.props.history.goBack();
这是解决我的要求,希望对您有帮助。
答案 2 :(得分:0)
至少在我看来,使用Ionic + React时这种行为是无法预测的。我总是得到路由器的长度在导航时总是大于1
,即使它IS
正在呈现的第一页也是如此。当用户单击exit
时,我正在尝试back button
的应用程序,这是首次呈现应用程序时的第一个视图