无法删除 React Native 应用程序中的标头

发布于 2025-01-17 04:29:25 字数 1396 浏览 0 评论 0原文

我是构建 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

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苄①跕圉湢 2025-01-24 04:29:25

您需要为每个导航器设置 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文