Ionicon将不会在React Native BottomTabNavigator上显示

时间:2019-05-13 16:47:30

标签: react-native ionicons react-native-vector-icons

我正在尝试使用react-navigation设置一个简单的屏幕导航栏。我已经可以进行导航,但是无法在每个标签上显示任何图标。

我尝试使用FontAwesome代替IonicIcons,但是出现带有X的相同Box代替了所需的图标。

import React, {Component} from 'react';
import {createBottomTabNavigator, createAppContainer} from 'react-navigation';
import Icon from 'react-native-vector-icons/Ionicons';

import HomeScreen from './screens/HomeScreen'
import SearchScreen from './screens/SearchScreen'
import ScanScreen from './screens/ScanScreen'

const TabNavigator = createBottomTabNavigator({
  Home: {
    screen: HomeScreen,
    navigationOptions: {
    tabBarIcon: () => (<Icon name="md-home" />)
    }
  },
  Scan: {
    screen: ScanScreen
  },
  Search: {
    screen: SearchScreen
  }
});

export default createAppContainer(TabNavigator);

1 个答案:

答案 0 :(得分:2)

您必须在命令提示符下将其链接为react-native-vector-icons:

 react-native link react-native-vector-icons