react 页面跳转参数传值

A页面向B页面传递参数:

A页面代码如下:

事件方法toOrderDetail()

toOrderDetail(item){

  //this.props.navigation.push('跳转的目标页面', { 参数名: 参数值 })

  this.props.navigation.push('B', { order_id: item.order_id })

}

B页面接收参数代码如下:

在生命周期componentDidMount中处理

componentDidMount() {
  alert('上个页面传过来的参数:'+this.props.navigation.state.params.order_id)
  
  this.setState({
            order_id:this.props.navigation.state.params.order_id
        })
}
 
 

猜你喜欢

转载自www.cnblogs.com/james-L/p/11906903.html