Bri*_*Lee 2 react-native react-navigation
我正在使用React Native和react-navigation制作应用程序.
[我的应用程序的层次结构]
*抽屉(APP)
ㄴStackNavigator
ㄴStackNavigator
我想要的是火 navigation.navigate('DrawerOpen');
我可以通过从左边缘拖动来显示我的抽屉,但不是通过按导航标题左侧的"菜单按钮"触发它.我花了这么多次来存档这个.请帮我.
const Nav = StackNavigator({
mainnav_list:{
screen: (props) => <TodoList {...props} dbCollectionName={props.screenProps.dbCollectionName}/>,
navigationOptions:({navigation}) => ({
headerLeft:(
<TouchableOpacity onPress={() => {console.log(navigation); navigation.navigate('DrawerOpen');}}>
<Text style={{color:'white', marginLeft:15}}>Menu</Text>
</TouchableOpacity>
)
})
},
mainnav_detail:{screen: TodoDetail}
}
,
{
navigationOptions:(props) => ({
title:props.screenProps.dbCollectionName,
headerBackTitle:null,
headerStyle:{backgroundColor:'#000'},
headerTitleStyle:{color:'#fff'},
headerTintColor:'#fff',
})
})
const AppDrawer = DrawerNavigator(
{
drawer1:{screen:() => <Nav screenProps={{dbCollectionName:'todos'}}/> },
drawer2:{screen:() => <Nav screenProps={{dbCollectionName:'todos2'}}/> }
})
AppRegistry.registerComponent('TodosFS', () => AppDrawer);
Run Code Online (Sandbox Code Playgroud)
在新版本的reactnavigation中打开,关闭或切换你DrawerNavigator只需使用以下内容即可
this.props.navigation.openDrawer();
this.props.navigation.closeDrawer();
this.props.navigation.toggleDrawer();
Run Code Online (Sandbox Code Playgroud)
https://reactnavigation.org/docs/en/drawer-based-navigation.html
| 归档时间: |
|
| 查看次数: |
2421 次 |
| 最近记录: |