如何设置 react 导航 v5 的头部选项?

问题描述 投票:0回答:1

伙计们我想用

static navigationOptions = ({ navigation  }) => {

}

我使用的是react导航v5告诉我,我的理解是正确的,现在可以使用Stack.Screen?Exapmle中的唯一选项来获得头部设置。

<Stack.Screen
        name="Home"
        component={HomeScreen}
        options={{
          title: 'My home',
          headerStyle: {
            backgroundColor: '#f4511e',
          },
          headerTintColor: '#fff',
          headerTitleStyle: {
            fontWeight: 'bold',
          },
        }}
      />
    </Stack.Navigator>
react-native react-navigation react-navigation-v5
1个回答
1
投票

你可以使用 navigation.setOptions({ title: 'Updated!' }) 来修改所需的导航选项。


0
投票

您可以在屏幕组件中使用navigation.setOptions编辑屏幕的导航选项。https:/reactnavigation.orgdocsheaders#updating-options-with-setoptions。

© www.soinside.com 2019 - 2024. All rights reserved.