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
})
}