我正在使用反应导航来为我的应用制作侧面菜单。我暂时使用Logoff()方法打开菜单。我90%确信toggleDrawer()方法正常工作。 问题:选中后,该应用默认为“设置屏幕”。它不会打开抽屉。
import MainAppNavigator from './MainAppNavigator';
import WorkingEmailScreen from '../containers/EmailScreenContainer';
import WorkingPasswordScreen from '../containers/PasswordScreenContainer';
import WorkingAuthLoadingScreen from '../containers/AuthLoadingScreenContainer';
import WorkingConfirmRegisterScreen from '../containers/ConfirmRegisterScreenContainer';
import WorkingSplashScreen from '../containers/SplashScreenContainer';
import WorkingLoginScreen from '../containers/LoginScreenContainer';
import WorkingResetPasswordScreen from '../containers/ResetPasswordScreenContainer';
import SettingsScreen from '../screens/SettingsScreen';
import SideMenuDrawer from '../screens/SideMenuDrawer';
const RegistrationStack = createStackNavigator({
Email: WorkingEmailScreen,
Password: WorkingPasswordScreen,
Confirm: WorkingConfirmRegisterScreen,
});
const SettingsStack = createStackNavigator({
Settings: SettingsScreen,
});
const SideMenuNavigator = createDrawerNavigator({
Settings: {
screen: SettingsStack,
navigationOptions: {
drawerLabel: 'Demo Screen 1',
},
},
Password: {
screen: WorkingPasswordScreen,
navigationOptions: {
drawerLabel: 'Demo Screen 2',
},
},
}, {
contentComponent: SideMenuDrawer,
});
export default createSwitchNavigator({
AuthLoading: WorkingAuthLoadingScreen,
App: MainAppNavigator,
Auth: RegistrationStack,
Splash: WorkingSplashScreen,
Login: WorkingLoginScreen,
ResetPassword: WorkingResetPasswordScreen,
SideMenu: SideMenuNavigator,
},
{
initialRouteName: 'AuthLoading',
});
MainScreen.js
// this.props.navigation.dispatch(DrawerActions.toggleDrawer());
this.props.navigation.dispatch(DrawerActions.toggleDrawer())
}