无法读取未定义的属性'routeName' - 反应导航抽屉

问题描述 投票:1回答:1

每次我将值传递给抽屉配置时,我都会收到此错误,但是当我使用它而不传递任何配置时,它可以正常工作。

我使用这个得到错误:

const Drawer = DrawerNavigator({
 AboutUs: { screen: AboutUsScreen },
 Options: { screen: OptionsScreen },
  Home: { screen: HomeScreen }
  }, {
  initialRouteName: 'Home',
   drawerPosition: 'right',
  });

使用这个没有错误:

   const Drawer = DrawerNavigator({
   AboutUs: { screen: AboutUsScreen },
   Options: { screen: OptionsScreen },
   Home: { screen: HomeScreen }
   });

我花了好几个小时试图搞清楚但没有运气。

完整代码:

import React, { Component } from 'react';
 import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';

import { Card, ListItem, Button, Icon } from 'react-native-elements'
import { DrawerNavigator } from 'react-navigation'
import HomeScreen from './Home'
import OptionsScreen from './Options'
import AboutUsScreen from './AboutUs'


const Drawer = DrawerNavigator({
AboutUs: { screen: AboutUsScreen },
Options: { screen: OptionsScreen },
Home: { screen: HomeScreen }
}, {
initialRouteName: 'Home',
drawerPosition: 'right',
});


export default Drawer ;
javascript reactjs react-native react-router
1个回答
1
投票

我已经添加了:

 drawerOpenRoute: 'DrawerOpen',
 drawerCloseRoute: 'DrawerClose',
 drawerToggleRoute: 'DrawerToggle'

抽屉配置,它现在正在工作:)

© www.soinside.com 2019 - 2024. All rights reserved.