【问题标题】:react native vector icons/fontawesome not showing icons in expo cli反应原生矢量图标/fontawesome 未在 expo cli 中显示图标
【发布时间】:2019-09-25 09:49:29
【问题描述】:

我在snack expo 中使用fontawsome 图标构建了布局,但是在expo cli 中运行相同的项目时,图标不显示。它显示为交叉。应用程序在snack 中完美运行,但在expo cli 中没有。我尝试过google问题,但解决方案是在 gradle 中更改文件,我没有 gardle 文件,这是一个小吃项目。有什么解决方案,任何帮助都会很好,谢谢。

import Icon from 'react-native-vector-icons/FontAwesome';

  {
    Home: {
      screen: FetchNewsApp,
      navigationOptions: {
        tabBarLabel: 'Home',
        tabBarIcon: ({ tintColor }) => (
          <Icon name="home" color={tintColor} size={25} />
        ),
      },
    },

    Explore: {
      screen: ExploreScreenApp,
      navigationOptions: {
        tabBarLabel: 'Explore',
        tabBarIcon: ({ tintColor }) => (
          <Icon name="wpexplorer" color={tintColor} size={25} />
        ),
      },
    },

    Search: {
      screen: SearchScreenApp,
      navigationOptions: {
        tabBarLabel: 'Search',
        tabBarIcon: ({ tintColor }) => (
          <Icon name="search" color={tintColor} size={25} />
        ),
      },
    },

    Settings: {
      screen: SettingScreenApp,
      navigationOptions: {
        tabBarLabel: 'Settings',
        tabBarIcon: ({ tintColor }) => (
          <Icon name="cog" color={tintColor} size={25} />
        ),
      },
    },

    Profile: {
      screen: ProfileScreenApp,
      navigationOptions: {
        tabBarLabel: 'Profile',
        tabBarIcon: ({ tintColor }) => (
          <Icon name="user-circle" color={tintColor} size={25} />
        ),
      },
    },
  },
  {
    initialRouteName: 'Home',
  }
);

【问题讨论】:

  • 发布一些代码。
  • 和导入声明
  • 在问题中添加代码而不是在 cmets 中

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


【解决方案1】:

如果您使用的是世博管理应用程序,只需使用世博矢量图标 Expo vector icons

因为 react 原生矢量图标需要链接,而这在 expo 托管应用程序中是不可能的。

这里是小吃博览会图标的示例: Snack

【讨论】:

    【解决方案2】:

    您还可以使用图像替换图标,效果很好,

    tabBarIcon: ({ tintColor }) => ( <Image source={require('...')} style={{}}/> )

    【讨论】:

    • 我不想使用图像,因为它需要太多时间来加载。无论如何谢谢
    • ionicons 在 expo 项目和 ios 设备中运行良好,但在 android 设备中无法运行
    • 实际上它对我来说很好用。只有 ion 和 md 与 expo cli 配合得很好。
    猜你喜欢
    • 1970-01-01
    • 2020-07-08
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-15
    相关资源
    最近更新 更多