0

我正在尝试将图标添加到以下简单的React Navigation DrawerNavigator

  export default createAppContainer(createDrawerNavigator({
  Home: {
    screen: HomeScreen,
    icon: 'home'
  },
  Screen1: {
    screen: Screen1
  },
  Screen2: {
    screen: Screen2
  },
  Screen3: {
    screen: Screen3
  },
}));

抽屉显示正常,但图标不是。

4

2 回答 2

0

确保您已导入反应原生矢量图标以在您的任何组件中使用图标。

 import Ionicons from 'react-native-vector-icons/Ionicons';
    export default createAppContainer(createDrawerNavigator({
    Home: {
    screen: HomeScreen,
    navigationOptions: {
      drawerIcon: () => <Ionicons name="ios-home" size={30} style={{ width: 24 }} 
    color="#000" />
    }
    },
    Screen1: {
    screen: Screen1
    },
    Screen2: {
    screen: Screen2
    },
      Screen3: {
    screen: Screen3
      },
    }));
于 2019-03-01T04:42:47.433 回答
0

图标必须是类似<Image>or的组件<View>,而不是字符串。

于 2019-02-28T22:00:28.647 回答