【问题标题】:React Go back to previous state [duplicate]反应回到以前的状态[重复]
【发布时间】:2018-03-29 15:54:49
【问题描述】:

我是新手,使用 react bootstrap table 来显示客户列表,然后单击每一行应该返回到详细视图。我正在寻找一种从详细信息页面返回列表视图的方法。我怎样才能做到这一点?

【问题讨论】:

  • 那回去会在哪个动作上呢?一些“返回”按钮或其他什么?
  • 返回按钮类似于“站点列表视图”
  • 在 onClick 处理程序中使用this.props.history.goBack(),它将导航到上一页。

标签: reactjs react-native react-router


【解决方案1】:

工作解决方案:

react-router (v4) how to go back?

constructor(props){
   super(props);
   this.goBack = this.goBack.bind(this); // i think you are missing this
}

goBack(){
    this.props.history.goBack();
}

.....

<button onClick={this.goBack}>Go Back</button>

【讨论】:

    猜你喜欢
    • 2020-10-28
    • 1970-01-01
    • 2018-11-13
    • 2020-08-23
    • 1970-01-01
    • 2022-08-19
    • 1970-01-01
    • 2021-09-30
    • 2019-02-27
    相关资源
    最近更新 更多