【发布时间】:2020-10-07 11:47:50
【问题描述】:
我有一个这样创建的菜单:
import {createStackNavigator} from 'react-navigation';
const stackNav = createStackNavigator({
Main: {
screen: JourneeService,
navigationOptions: ({navigation}) => ({
headerTitle: <StackNavTitle title="Journée de Service " />,
headerStyle: {
backgroundColor: '#0088CE',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
headerLeft: (
<TouchableOpacity
onPress={() => navigation.openDrawer()}
style={{width: '150%'}}>
<Icon name="ios-menu" size={35} color="#fff" style={{padding: 10}} />
</TouchableOpacity>
),
}),
}
使用 StackNavTitle :
class StackNavTitle extends Component {
constructor(props){
super(props);
}
render() {
return <Text style={{fontWeight: 'bold', color:'#fff', fontSize:20}}>
{this.props.title}.
</Text>;
}
}
在代码上我通过回调检索标题我想动态设置标题我该怎么做?
提前感谢您的回复
【问题讨论】:
标签: react-native navigation stack-navigator