【发布时间】:2021-10-29 01:27:59
【问题描述】:
我只是在上 React Native 的课程,并且无法使用 Drawer Navigator 获得任何道具。我在 Mac M1 上使用 iOS Simulator (14.3) 和 WebStorm IDE。我也在使用裸 React Native,而不是 Expo。
我在下面附上了我的 App.js 代码。正如您将看到的,它非常基本,但 initialRouteName 是唯一有效的道具。其他人都没有做他们应该做的事情。应用不会崩溃,道具只是不会按预期改变行为。
据我了解,iOS 支持这些道具。
有人可以帮忙吗?提前致谢。
import React from 'react';
import { StyleSheet } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
// screen code held in separate .js files
import ScreenA from "./ScreenA";
import ScreenB from "./ScreenB";
import { createDrawerNavigator } from "@react-navigation/drawer";
const Drawer = createDrawerNavigator();
function App() {
return(
<NavigationContainer>
<Drawer.Navigator
initialRouteName={'Screen B'} // works fine
drawerPosition={"right"} // not working
drawerType={'front'} // not working
edgeWidth={800} // not working
hideStatusBar={true} // not working
overlayColor={'#000000'} // not working
drawerStyle={{
backgroundColor: '#56cb6a' // not working
}}
>
<Drawer.Screen name={'Screen A'}
component={ScreenA}
/>
<Drawer.Screen name={'Screen B'}
component={ScreenB}
/>
</Drawer.Navigator>
</NavigationContainer>
)
}
【问题讨论】:
标签: javascript ios react-native navigation-drawer webstorm