我需要隐藏我尝试过的应用程序的登陆页面上的导航栏:
const Stack = createStackNavigator(
{
Landing: {screen: LandingScreen},
},
{
headerMode: 'none',
navigationOptions: {
headerVisible: false,
},
},
);
但我收到一条错误消息:
“创建一个导航器不需要争论......”
当我使用headerMode="none"
它隐藏所有屏幕上的导航栏
<NavigationContainer>
<Stack.Navigator
headerMode="none" // this hides on all screens
screenOptions={{
headerStyle: {
backgroundColor: '#3c74db',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
}}>
<Stack.Screen
name="Landing"
component={LandingScreen}
options={{headerShown: 'none'}} // This does not work
/>
<Stack.Screen name="Sales" component={SalesScreen} />
<Stack.Screen name="Sign In" component={SignInScreen} />
<Stack.Screen name="Register" component={RegisterScreen} />
<Stack.Screen name="Create Item" component={CreateItemScreen} />
<Stack.Screen name="Payment" component={PaymentScreen} />
</Stack.Navigator>
</NavigationContainer>
那么如何才能只在一个屏幕上隐藏呢?
反应导航 v5.x
The options https://reactnavigation.org/docs/stack-navigator/#optionsprop 可用于配置导航器内的各个屏幕。您可以使用headershown
option:
是否显示或隐藏屏幕标题。除非 headerMode 设置为 none,否则默认显示标头。将其设置为 false 会隐藏标题。在特定屏幕上隐藏标题时,您可能还需要将 headerMode 属性设置为屏幕。Docs https://reactnavigation.org/docs/stack-navigator/#headershown.
<Stack.Navigator ...>
...
<Stack.Screen
name="Landing"
component={LandingScreen}
options={{
headerShown: false, // change this to `false`
}}
/>
...
</Stack.Navigator>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)