headerLeft在reactNavigation V3中不起作用

时间:2019-08-07 23:20:49

标签: react-native react-navigation

我检查了以前的答案,并尝试了其他方法,但仍然无法正常工作。仅当我在屏幕内使用静态NavigationOptions时才有效

我尝试使用defaultNavigationOptions,但不起作用,其上的navigationOptions也不起作用

TIMETABLE = createStackNavigator(
    {
        timetable: {
            screen: timetable,
            defaultNavigationOptions: {
                title: i18n.t('TIMETABLE'),
                headerStyle,
                headerTitleStyle,
                headerLeft: (
                    <Button
                        title="oi"
                        color="#fff"
                    />
                )
            }
        }
    }
);

the above does not work and neither the below code: 

TIMETABLE = createStackNavigator(
    {
        timetable: {
            screen: timetable,
            navigationOptions: {
                title: i18n.t('TIMETABLE'),
                headerStyle,
                headerTitleStyle,
                headerLeft: (
                    <Button
                        title="oi"
                        color="#fff"
                    />
                )
            }
        }
    }
);

期望在堆栈导航器标题的左侧看到一个标题为“ oi”的按钮,但没有按钮出现。

1 个答案:

答案 0 :(得分:0)

不是因为您的button背景是白色的吗?

               navigationOptions: {
                title: i18n.t('TIMETABLE'),
                headerLeft: (
                  <View style={{paddingLeft: 20}}>
                    <Button
                        title="oi"
                        color="black"
                    />
                    </View>
                )
            }

Example of button execution