我希望创建一个自定义抽屉导航器与一些可扩展的列表视图与一些隐藏的路线。
例如。
主页
Main1
隐藏1
隐藏为
hid b
隐藏2
隐藏为
hid b
其中hid和hid将隐藏在HID1或HID2之后。当HID1或HID2被点击或触摸时,将显示hid /hid。
这就是我到目前为止所得到的--
Main.js:
export default function MainScreen({ navigation }){
return (
<NavigationContainer>
<Drawer.Navigator initialRouteName='Home' drawerContent={props => <Menu {... props} />}>
<Drawer.Screen name=".." options={{drawerIcon: config => <Icon name=".." size={22} color="#000"></Icon>}} component={HomeScreen} />
<Drawer.Screen name="Ex1" component={Ex1} />
<Drawer.Screen name="Ex2" component={Ex2} />
<Drawer.Screen name="Ex3" component={Ex3} />
<Drawer.Screen name="Ex4" component={Ex4} />
<Drawer.Screen name="Ex5" component={Ex5} options={{
title:"..",
drawerIcon: config => <Icon
size={22}
name='..'></Icon>
}} />
</Drawer.Navigator>
</NavigationContainer>
)
}Menu.js:
const Menu = (props) => {
return (
<SafeAreaView style={{flex: 1}}>
<DrawerContentScrollView {...props}>
<DrawerItemList {...props} />
</DrawerContentScrollView>
</SafeAreaView>
);
};我正在寻找拆分DrawerItemList,这样我就可以在下拉列表中显示我的一些路由。
上面示例中的大部分代码都经过了清理,因为其中许多代码是商业敏感的,但我可以向您保证,我的组件名称等在实际代码中要好得多。
如有任何建议或意见,我们将不胜感激。
我刚刚开始使用react-native,对我来说太空洞了。
如果你需要更多的信息,请不要犹豫评论和询问。
提前谢谢。
发布于 2021-05-11 05:26:16
解决方案是对包含DrawerItems的可折叠视图使用@eliav2/react-native- collapsible view。
https://stackoverflow.com/questions/67462708
复制相似问题