注意:如果有什么遗漏,请指导我。我有一个抽屉导航器,其中包含抽屉屏幕是堆栈屏幕,如:
<PaperProvider theme={theme}>
<NavigationContainer>
<Drawer.Navigator
screenOptions={({ }) => ({
// headerShown: false,
// title:"",
headerTransparent: true,
headerTitle: "",
})}>
<Drawer.Screen name="Home" component={HomeScreen} />
<Drawer.Screen name="Groups" component={GroupsScreen} />
<Drawer.Screen name="Rides" component={RidesScreen} />
</Drawer.Navigator>
</NavigationContainer>
</PaperProvider>
问题是抽屉导航器的标题汉堡包显示在主屏幕和每一个助手屏幕等。我想在第一个屏幕上显示“HomeHelper”,但想隐藏在它导航到的其他屏幕上,如“ListOfRides”屏幕。
主屏幕:
<Stack.Navigator
screenOptions={() => ({
headerTitle: "",
headerTransparent: true,
//headerShown:false
})}>
{rideBooked == true ? (
<Stack.Screen name="Screen1" component={Screen}
options={{
headerRight: () => (
<Button
onPress={() => alert('This is a button!')}
>Cancel</Button>
),
}}/>
) : (
<>
{/* headertransparent for these */}
<Stack.Screen name="HomeHelper" component={HomeHelperScreen} />
<Stack.Screen name="ListOfRides" component={ListOfRidesScreen} />
</>
)}
</Stack.Navigator>
1条答案
按热度按时间mwg9r5ms1#