【问题标题】:How to show the "Back" in the header of React Native for the immediately previous screen only in multiple Stacks?如何仅在多个堆栈中显示前一个屏幕的 React Native 标题中的“返回”?
【发布时间】:2019-11-25 23:42:37
【问题描述】:

当你有多层的 React Navigation 堆栈时,我如何设置屏幕标题,以便当你按下 Back 时,它只会向后退一步。例如,当我们有屏幕 A -> 屏幕 B -> 屏幕 C 时,我们如何设置标题,以便一旦用户到达屏幕 C,屏幕 A 的标题是隐藏的,只有屏幕 B 的标题是显示?

Profile: {
    screen: createStackNavigator({
        Profile: {
            screen: ProfileScreen,
            navigationOptions: {
                header: null,
            }
        },
        MyItems: {
            screen: createStackNavigator({
                MyItems: {
                    screen: MyItemsScreen,   
                    navigationOptions: {
                        header: null,
                    }
                },
                PostingDetail: {
                    screen: PostingDetailScreen,
                    navigationOptions: {
                        header: null,
                    }
                },
            })
        },
    }),

这显示了Back 将用户带回到第一个屏幕屏幕 A,在这种情况下是 Profile,从屏幕 C,PostingDetail,但不会将屏幕 C 带回屏幕 B。

【问题讨论】:

  • 对不起,这很难理解。可以给我看视频吗?

标签: react-native react-navigation react-native-navigation


【解决方案1】:

这种可能性也可能发生,因为您直接从屏幕 A 导航到屏幕 C。因为您打开的每个屏幕都被推入堆栈,如果您使用 goBack() 该函数只需从堆栈中拉出最后一个屏幕并在该屏幕上导航。您能否分享更多导航到屏幕的代码

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-11
    • 2018-03-18
    • 2022-11-09
    • 1970-01-01
    • 2021-12-01
    • 1970-01-01
    • 2019-10-23
    • 2021-09-10
    相关资源
    最近更新 更多