我必须在两侧都做两个抽屉,并在底部有一个标签导航器。我试图用react-navigation来做到这一点,但是我不能,因为openDrawer代码只是打开其中一个,所以我坚持了,请帮助我。如何提供抽屉ID,密钥或其他方法。
反应原生
<Button onPress={this.props.navigation.openDrawer}>
<Button/> //left drawer opens
<Button onPress={this.props.navigation.openDrawer}>
<Button/>
我尝试了您的代码,但出现TypeError:undefined不是对象 (评估“ 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>
答案 0 :(得分:0)
每个drawerNavigator
可以是positioned
并命名为Route。 Position
可以设置为右或左。然后通过命令打开所需的drawer
。
示例
let LeftSideMenuDrawer = createDrawerNavigator({
...
drawerOpenRoute: 'LeftSideMenu',
drawerCloseRoute: 'LeftSideMenuClose',
drawerToggleRoute: 'LeftSideMenuToggle',
....
用法
this.props.navigation.dispatch(DrawerActions.openDrawer('LeftSideMenu'));