React native React Native-使用Navigation.push()时打开抽屉不工作
我正在开发一个React Native Expo应用程序,其中我有堆栈导航和抽屉导航。 我在app.js的堆栈导航器中嵌套了抽屉导航器。当我点击抽屉汉堡菜单时,它会从右边打开抽屉。它在所有屏幕上工作正常,没有任何问题 当我决定使用这个.props.navigation.push(“付款”)来推到付款屏幕时,问题出现了。 使用navigation.push()时,OpenDrawer()函数不会作为道具的一部分传递,而使用navigation.navigate()时,它工作正常 OpenDrawer()函数在我使用下面的语句导航到付款屏幕时起作用 这个.props.navigation.navigate(“付款”) OpenDrawer()函数在我使用下面的语句导航到该屏幕时抛出“函数未找到”错误 这个.props.navigation.push(“付款”) 下面是我的app.js,我将抽屉嵌套在堆栈导航器中。有人能告诉我如何解决这个问题吗。谢谢 app.jsReact native React Native-使用Navigation.push()时打开抽屉不工作,react-native,navigation-drawer,react-navigation-drawer,React Native,Navigation Drawer,React Navigation Drawer,我正在开发一个React Native Expo应用程序,其中我有堆栈导航和抽屉导航。 我在app.js的堆栈导航器中嵌套了抽屉导航器。当我点击抽屉汉堡菜单时,它会从右边打开抽屉。它在所有屏幕上工作正常,没有任何问题 当我决定使用这个.props.navigation.push(“付款”)来推到付款屏幕时,问题出现了。 使用navigation.push()时,OpenDrawer()函数不会作为道具的一部分传递,而使用navigation.navigate()时,它工作正常 OpenDrawe
import React from "react";
import {
Dimensions,
ScrollView,
Button,
View,
SafeAreaView,
} from "react-native";
import { createStackNavigator } from "@react-navigation/stack";
import {
createDrawerNavigator,
DrawerContentScrollView,
} from "@react-navigation/drawer";
import {
NavigationContainer,
useNavigation,
DrawerItem,
} from "@react-navigation/native";
import Landingzone from "./components/Landingzone";
import LandingPage from "./components/LandingPage";
import Summary from "./components/Summary";
import Payment from "./components/Payment";
import { TouchableOpacity } from "react-native-gesture-handler";
import { Icon, Text } from "react-native-elements";
const myFont = Platform.OS === "ios" ? "Arial" : "sans-serif";
let myFontSize = 15;
const SCREEN_WIDTH = Dimensions.get("window").width;
if (SCREEN_WIDTH > 300 && SCREEN_WIDTH <= 360) {
myFontSize = 10;
} else if (SCREEN_WIDTH > 300 && SCREEN_WIDTH <= 415) {
}
export default function App() {
const Stack = createStackNavigator();
const Drawer = createDrawerNavigator();
const DrawerNavigator = () => (
<Drawer.Navigator
drawerPosition="right"
drawerContentOptions={{
labelStyle: {
color: "white",
fontFamily: myFont,
fontSize: 16,
},
}}
drawerStyle={{
backgroundColor: "#343a40",
flex: 1,
flexDirection: "column",
}}
drawerContent={(props) => (
<DrawerContentScrollView
contentContainerStyle={{
flex: 1,
flexDirection: "column",
}}
>
<View
style={{
flex: 0.15,
}}
>
<Icon
reverse
name="user-circle-o"
type="font-awesome"
color="#517fa4"
containerStyle={{
backgroundColor: "green",
left: 115,
}}
/>
<Text>SaimugaTutorials@gmail.com</Text>
</View>
<View
style={{
flex: 0.1,
justifyContent: "center",
}}
>
<Text>Enroll</Text>
</View>
</DrawerContentScrollView>
)}
>
<Drawer.Screen
name="Summary"
component={Summary}
options={{ headerShown: false }}
/>
<Drawer.Screen
name="Payment"
component={Payment}
options={{ headerShown: false }}
/>
</Drawer.Navigator>
);
const StackNavigator = () => (
<Stack.Navigator initialRouteName="Welcome">
<Stack.Screen
name="Welcome"
component={LandingPage}
options={{ headerShown: false }}
/>
<Stack.Screen
name="Payment"
component={Payment}
options={{ headerShown: false }}
/>
<Stack.Screen
name="Summary"
component={DrawerNavigator}
options={{ headerShown: false, gestureEnabled: false }}
/>
</Stack.Navigator>
);
return (
<NavigationContainer>
<StackNavigator />
</NavigationContainer>
);
}
从“React”导入React;
进口{
尺寸,
滚动视图,
按钮
看法
安全区域视图,
}从“反应本族语”;
从“@react navigation/stack”导入{createStackNavigator};
进口{
createDrawerNavigator,
DroperContentScrollView,
}来自“@react导航/抽屉”;
进口{
导航容器,
使用导航,
抽屉式,
}从“@react-navigation/native”;
从“/components/Landingzone”导入着陆区;
从“/components/LandingPage”导入LandingPage;
从“/components/Summary”导入摘要;
从“/组件/付款”导入付款;
从“反应本机手势处理程序”导入{TouchableOpacity};
从“react native elements”导入{Icon,Text};
const myFont=Platform.OS==“ios”?“Arial”:“无衬线”;
设myFontSize=15;
const SCREEN_WIDTH=尺寸。获取(“窗口”)。宽度;
如果(屏幕宽度>300和屏幕宽度300和屏幕宽度(
(
SaimugaTutorials@gmail.com
登记
)}
>
);
const StackNavigator=()=>(
);
返回(
);
}
有关于此的更新吗?有关于此的更新吗?