【发布时间】:2020-12-18 04:23:36
【问题描述】:
您好,我是 react native 的新手,如何在 react native 中实现抽屉导航器。其实我正在关注这个文档
更新:
首页代码如下
constructor(props){
super(props)
this.state= {
icon: null
}
}
render(){
return(
<Container>
<Header style={{backgroundColor:'pink'}} >
<Button
transparent
onPress= {() => this.props.navigation.navigate("DrawerOpen")}>
<Icon
style= {{color: '#ffffff', fontSize:25, paddingTop:0}}
name="bars"
/>
</Button>
</Header>
<Content>
</Content>
</Container>
);
}
}
还有
index.js
import CourseListing from './CourseListing';
import SideBar from './SideBar/SideBar';
import {DrawerNavigator} from 'react-navigation';
import Profile from './Profile';
const MyHome =DrawerNavigator(
{
CourseListing: {screen: CourseListing},
Profile: {screen: Profile},
},
{
contentComponent: props => <SideBar {...props} />
}
);
【问题讨论】:
-
您使用哪个库进行导航?
-
我正在使用
react-navigation -
使用 react-native-router-flux 库而不是 react-navigation。它提供了简单的文档来集成抽屉菜单和屏幕之间的导航。
-
这很简单。你哪里有问题?
标签: react-native navigation-drawer