无法删除 React Native 应用程序中的标头
我是构建 React Native 应用程序的新手,但我在 Android Studio 方面确实有一点经验,我为此使用 Stack.Navigatior
但我已经通过设置 隐藏了标题headerShown: false
,当我尝试 headerShown: true
时,它会附加另一个标头,所以我只需要保留为 false,但另一个标头仍然存在,我只想删除标头如上所述,但是如何呢?需要帮助
import React from 'react';
import { CryptoDetail, Transaction } from "./screens";
import { createStackNavigator } from "@react-navigation/stack";
import { NavigationContainer } from '@react-navigation/native';
import SplashScreen from 'react-native-splash-screen';
import Tabs from "./navigation/tabs";
const Stack = createStackNavigator();
const App = () => {
React.useEffect(() =>{
SplashScreen.hide()
},[])
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerShown: false
}}
initialRouteName={'Home'}
>
<Stack.Screen
name="Home"
component={Tabs}
/>
<Stack.Screen
name="CryptoDetail"
component={CryptoDetail}
/>
<Stack.Screen
name="Transaction"
component={Transaction}
/>
</Stack.Navigator>
</NavigationContainer>
)
}
export default App;
I'm new in building a react native app but I do have experience in android studio little bit, I'm using Stack.Navigatior
for this but I've already hide the header by setting headerShown: false
, When I've tried headerShown: true
it will append another header so I just need to remain to false but the other one still exists, I just want to remove the header above, but how? need help for this
import React from 'react';
import { CryptoDetail, Transaction } from "./screens";
import { createStackNavigator } from "@react-navigation/stack";
import { NavigationContainer } from '@react-navigation/native';
import SplashScreen from 'react-native-splash-screen';
import Tabs from "./navigation/tabs";
const Stack = createStackNavigator();
const App = () => {
React.useEffect(() =>{
SplashScreen.hide()
},[])
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerShown: false
}}
initialRouteName={'Home'}
>
<Stack.Screen
name="Home"
component={Tabs}
/>
<Stack.Screen
name="CryptoDetail"
component={CryptoDetail}
/>
<Stack.Screen
name="Transaction"
component={Transaction}
/>
</Stack.Navigator>
</NavigationContainer>
)
}
export default App;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要为每个导航器设置
headerShown: false
,而不仅仅是一个。在代码中的某个位置,例如在“选项卡”组件中,您有另一个导航器,您也需要在那里设置它。You need to set
headerShown: false
for every Navigator, not just one. Somewhere in your code, for example in the "Tabs" component, you have another Navigator and you need to set it there too.