关键属性 headerLeft, navigation.state.params, navigation.setParams
static navigationOptions = ({ navigation }) => {
return {
title: '我是一个页面',
headerStyle: {
backgroundColor: '#4E86F7',
},
headerTintColor: '#fff',
headerLeft:(
<TouchableOpacity onPress= {()=>navigation.state.params.handleBack()} >
<Image
resizeMode={'contain'}
source={require('../backIcon.png')}
style={{width: 25, height: 25}} />
</TouchableOpacity>
)
}
}
componentDidMount() {
//componentDidMount阶段在navigation挂载
this.props.navigation.setParams({handleBack:this._handleAdd})
}
_handleAdd(){
console.log('我监听了返回键')
}
既然能够设置传递函数,那么传递参数不就更简单了
//有空在写