首页 新闻 会员 周边

react-native 如何关闭返回按钮

0
[待解决问题]

头部的返回按钮如何关闭

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View,Button,StatusBar,TouchableOpacity,Image} from 'react-native';
export default class page1 extends Component {
static navigationOptions = ({ navigation }) => {
return {
header: () => null, // 隐藏头部
}
};
render() {
const {navigation} = this.props;
return (
<View>
<StatusBar backgroundColor="#0187FB" barStyle="light-content" />
<View style={styles.header}>
<View style={styles.flex1}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('DrawerOpen')} style={{alignSelf:'flex-start',marginLeft:10}}>
<Image source={require('../images/logo.png')} style={styles.avatar} />
</TouchableOpacity>
</View>
<View style={styles.flex1}>
<Text style={styles.title}>消息</Text>
</View>
<View style={styles.flex1}>
<TouchableOpacity onPress={() => console.log(1231231)} style={{alignSelf:'flex-end',marginRight:10}}>
<Text style={styles.add}>+</Text>
</TouchableOpacity>
</View>
</View>
<Button
title='Go Back'
onPress={()=>{
navigation.goBack()
}}
/>
<Button
title='跳转到page2'
onPress={()=>{
navigation.navigate('Page2');
}}
/>
</View>
);
}
}

const styles = StyleSheet.create({
header: {
height: 60,
flexDirection: 'row',
backgroundColor: '#0187FB',
borderBottomWidth: 1,
borderColor: '#ddd'
},
flex1: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
avatar: {
width: 50,
height: 50,
borderRadius: 25
},
title: {
fontSize: 20,
color: '#fff'
},
add: {
fontSize: 30,
color: '#fff',
}
});

一叶*秋的主页 一叶*秋 | 初学一级 | 园豆:5
提问于:2018-12-01 12:09
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册