react-native - 禁用特定屏幕的抽屉
问题描述
我有如下实现抽屉导航器,我有如下堆栈导航器,
function MyStack() {
return (
<NavigationContainer>
<Drawer.Navigator initialRouteName="Home" drawerStyle={{ width: (window.width) * 0.75 }}
drawerContent={(props) => <DrawerContent {...props} />}>
<Drawer.Screen name="Home" children={createHomeStack} />
</Drawer.Navigator>
</NavigationContainer>
);
}
我的堆栈导航器如下,
createHomeStack = () =>
<Stack.Navigator screenOptions={{ headerShown: false }}>
<Stack.Screen
name="LandingPage" component={LandingPage}
/>
<Stack.Screen
name="LoginPage" component={LoginPage}
/>
<Stack.Screen
name="SignUpPage" component={SignUpPage}
/>
<Stack.Screen
name="DashboardPage" component={DashBoardPage}
/>
<Stack.Screen
name="OffersPage" component={OffersPage}
/>
<Stack.Screen
name="ProfilePage" component={ProfilePage}
/>
</Stack.Navigator>
我想禁用 LandingPage、LoginPage、SignUpPage 的抽屉并仅启用其余屏幕的抽屉。谁能帮我存档这个目标?
解决方案
您可以 通过检查您的路线页面将swipeEnabled=false添加到Drawer.Screen
<Drawer.Screen
options={({ route, navigation }) => {
return {
swipeEnabled: false,
};
}}/>
推荐阅读
- c++ - 如何从 C 宏调用 C++ 重载函数
- php - 无法使用 twilio 代理记录通话
- filter - 如何在 Power BI 中创建和使用日历筛选器
- javascript - 更改由 google Places API 自动完成方法调用的 formatted_address 的语言
- python - 如何让机器人通过 REST API 依次发送多条消息?[拉萨]
- javascript - 引导程序中的自动轮播
- javascript - 使用 JavaScript 动态创建规范 URL
- excel - 如何在受保护的工作表上断开指向 VBA 中值的链接?运行时错误“1004”
- terraform - 分配地图时 Terraform 何时需要等号 (=) (TF 0.11)
- javascript - setAttribute 不适用于 create-react-app 中的 onClick