一、需求:
要实现在标题栏的右边部分添加自定义按钮
问题分析:
日常废话,这个真的是难者不会,会者不难,在研究多次无果之后,经过高人点拨,顿时。。。
使用:
class HearNavigation extends Component{
render(){
return(
<TouchableOpacity style={styles.msgContent}
>
<Image
source={require('./../../img/forward.png')}
style={styles.msgBg}
/>
</TouchableOpacity>
)
}
}
export default class CustomerDetail extends Component{
static navigationOptions = {
headerRight:<HearNavigation/>
}
}
二、需求:
标题栏右边文字加事件
使用:
class HearNavigation extends Component{
constructor(props){
super(props);
}
goPayList(){
navigationNewPush({
navigation:this.props.navigation,
route:'payList'
});
}
render(){
return(
<Text style={styles.msgContent}
onPress={()=>{
this.goPayList()
}}
>
点击
</Text>
)
}
}
export default class InsureList extends Component{
static navigationOptions = (props) => {
return{
headerRight:<HearNavigation {...props} />
}
}
}