【发布时间】:2020-05-03 12:06:21
【问题描述】:
我想创建自定义标题栏,因为产品屏幕到产品名称屏幕我想在标题栏中显示产品名称
【问题讨论】:
标签: react-native react-native-android react-native-ios react-native-flatlist react-native-navigation
我想创建自定义标题栏,因为产品屏幕到产品名称屏幕我想在标题栏中显示产品名称
【问题讨论】:
标签: react-native react-native-android react-native-ios react-native-flatlist react-native-navigation
试试这个, 更多帮助:- https://reactnavigation.org/docs/headers/
function HomeScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home Screen</Text>
<Button
title="Go to Profile"
onPress={() =>
navigation.navigate('Profile', { name: 'Custom profile header' })
}
/>
</View>
);
}
function ProfileScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Profile screen</Text>
<Button title="Go back" onPress={() => navigation.goBack()} />
</View>
);
}
function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{ title: 'My home' }}
/>
<Stack.Screen
name="Profile"
component={ProfileScreen}
options={({ route }) => ({ title: route.params.name })}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
【讨论】: