【问题标题】:How do I use tabBarOnLongPress in bottom navigation(react navigation v5)? [closed]如何在底部导航(反应导航 v5)中使用 tabBarOnLongPress? [关闭]
【发布时间】:2020-07-14 08:22:21
【问题描述】:

我找不到关于如何在反应导航 v5 上使用 tabBarOnLongPress 的示例或 sn-ps。如果有人已经这样做了,请帮忙?

【问题讨论】:

    标签: react-native react-native-android react-navigation react-native-ios react-navigation-v5


    【解决方案1】:

    如果您使用标准 TabNavigator,只需在屏幕组件中订阅 tabLongPress 事件即可。

    const unsubscribe = navigation.addListener('tabLongPress', (e) => {
       // Do something
    });
    

    小吃示例:https://snack.expo.io/HewmpqPQD

    如果您使用自定义选项卡导航器,请不要忘记发出 tabLongPress 事件。

    const onLongPress = () => {
              navigation.emit({
                type: 'tabLongPress',
                target: route.key,
              });
            };
    

    更多信息在这里:https://reactnavigation.org/docs/material-top-tab-navigator/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-02
      • 1970-01-01
      • 1970-01-01
      • 2021-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多