获取嵌套在createDrawerNavigator内的createStackNavigators initialRoute中的抽屉路线中的图标

时间:2018-12-13 13:05:08

标签: reactjs react-native react-navigation

我有一个createDrawerNavigator,左侧有一个抽屉,并且内部嵌套了一个createStackNavigator。 我试图获取抽屉中每条路线的图标,但对于createStackNavigators initialRoute,图标未出现enter image description here

由于配置文件前面没有图标,因此它是一个createStackNavigator 以及如何做到这一点。

代码: 具有导航结构的App.js文件

const MainNavigation = createDrawerNavigator(
{
  Home: ProductsScreen,
  Cart: CartScreen,
  Profile: createStackNavigator(
  {
    profilepage: ProfileScreen,
    form: ProfileFormScreen
  },
  {
    initialRouteName: "profilepage",
    mode: "card",
    navigationOptions: {
      header: null
    }
  }),
  Order: OrderScreen,
  Reminder: ReminderScreen
})

现在,在这里,嵌套的createStackNavigator无法捕获图标。

在抽屉式导航器中,每个屏幕都会捕获图标,因为静态导航选项在其屏幕类中给出...

喜欢:

static navigationOptions = {
  drawerIcon: (
    <Icon
      name="home"
      color="#007aff"
      type="materialicons"
      style={{ height: 24, width: 24 }}
    />
  )
}; <-- This is for like home screen in drawer, the same i have done in ProfileScreen as well, but its not working.

个人资料图标的屏幕代码:

static navigationOptions = {
  drawerIcon: (
    <Icon
      name="user"
      color="#007aff"
      type="font-awesome"
      style={{ height: 24, width: 24 }}
    />
  )
};

0 个答案:

没有答案