【问题标题】:How to open second drawer in REACT NATIVE如何在 REACT NATIVE 中打开第二个抽屉
【发布时间】:2019-08-22 13:50:10
【问题描述】:

我必须在两侧做 2 个抽屉和一个底部标签导航器。我试图用 react-navigation 来做,但我做不到,因为 openDrawer 代码只打开了其中一个,所以我卡住了,请帮帮我。如何提供抽屉 ID、钥匙或其他方法。

反应原生


<Button onPress={this.props.navigation.openDrawer}>
<Button/>  //left drawer opens 
<Button onPress={this.props.navigation.openDrawer}>
<Button/>

我试过你的代码,但我得到了 TypeError: undefined is not an object (评估“this.props.navigation.dispatch”)

<Button title='open the drawer' onPress={this.props.navigation.dispatch(DrawerActions.openDrawer('drawerOpenLeft'))}></Button>
        <Button title='open the drawer right' onPress={this.props.navigation.dispatch(DrawerActions.openDrawer('drawerOpenRight'))}></Button>

【问题讨论】:

    标签: react-native react-native-drawer


    【解决方案1】:

    每个drawerNavigator 可以是positioned 和路由命名。 Position 可以设置为 rightleft。然后通过命令打开你想要的drawer

    示例

    let LeftSideMenuDrawer = createDrawerNavigator({
    ...
        drawerOpenRoute: 'LeftSideMenu',
        drawerCloseRoute: 'LeftSideMenuClose',
        drawerToggleRoute: 'LeftSideMenuToggle',
    ....
    

    用法

    this.props.navigation.dispatch(DrawerActions.openDrawer('LeftSideMenu'));
    

    【讨论】:

    • 谢谢,我的朋友,我会尝试如果它有效,我会告诉你/
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多