简体   繁体   English

react-native-vector-icons/Feather Icon 总是“?”

[英]react-native-vector-icons/Feather Icon always “?”

Good Morning, I'm trying to use library https://github.com/oblador/react-native-vector-icons#installation早上好,我正在尝试使用库https://github.com/oblador/react-native-vector-icons#installation

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

After I installed it and followed every step of installation在我安装它并遵循安装的每一步之后

I tried to run it with expo with this code:我尝试使用以下代码使用 expo 运行它:

function BottomTabNavigator1() {
  return (
    <Tabs.Navigator
        tabBarOptions={
            {
            activeTintColor: "#2F7C6E",
            inactiveTintColor: "#222222"
            }
        }
        apperance={
            {
                whenInactiveShow : "both"
            }
        }
    >

    <Tabs.Screen name="HomeScreen" component={HomeScreen}
    options={
        {
            tabBarIcon: ({ focused, color, size }) => (
                <Icon
                    name="Home"
                    size={size ? size : 12}
                    color={focused ? color : "#222222"}
                    focused={focused}
                    color={color}
                />
            )
        }
    }
    />
    <Tabs.Screen name="DefaultScreen" component={DefaultScreen}
    options={
        {
            tabBarIcon: ({ focused, color, size }) => (
                <Icon
                    name="Rocket"
                    size={size ? size : 12}
                    color={focused ? color : "#222222"}
                    focused={focused}
                    color={color}
                />
            )
        }
    }
    />
  </Tabs.Navigator>
  )
}

No error messages appeared, but the and 'Home" won't show off, only shown on expo view as image '?'没有出现错误消息,但“主页”不会显示,仅在 expo 视图上显示为图像“?” Am I missing something? help please我错过了什么吗?请帮助

I think react-native-vector-icons doesn't support Expo as that package needs native modules to be linked which isn't supported in an Expo project unless you eject.我认为react-native-vector-icons不支持 Expo 因为 package 需要链接本机模块,这在 Expo 项目中不受支持,除非您弹出。

You can use @expo/vector-icons as an alternative instead.您可以使用@expo/vector-icons作为替代。

According to its docs:根据其文档:

This library is a compatibility layer around @oblador/react-native-vector-icons to work with the Expo asset system.该库是围绕@oblador/react-native-vector-icons 的兼容层,可与 Expo 资产系统一起使用。

In your case you can do the following:在您的情况下,您可以执行以下操作:

Replace:代替:

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

<Icon
  name="Home"
  size={size ? size : 12}
  color={focused ? color : "#222222"}
  focused={focused}
  color={color}
/>

With:和:

import { Feather } from '@expo/vector-icons';

<Feather
  name="home"
  size={size ? size : 12}
  color={focused ? color : "#222222"}
  focused={focused}
  color={color}
/>

You may need to run:您可能需要运行:

npm i @expo/vector-icons

Here is a snack to see the result: https://snack.expo.io/@dcangulo/2e6e4e这是一个看结果的零食: https://snack.expo.io/@dcangulo/2e6e4e

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 react-native-vector-icons /羽毛图标未显示 - react-native-vector-icons/Feather icons are not displayed 从&#39;react-native-vector-icons/Ionicons&#39; 导入图标 - import Icon from 'react-native-vector-icons/Ionicons' React-native-vector-icons + Icomoon 的自定义图标集问题 - Custom Icon Set Problem with React-native-vector-icons + Icomoon Feather - react-native-vector-icons - 可能处理了 promise 拒绝 (id:9) 问题 - Feather - react-native-vector-icons - possible handled promise rejection (id:9) issue 错误:捆绑失败:错误:无法解析模块`react-native-vector-icons/Feather` - error: bundling failed: Error: Unable to resolve module `react-native-vector-icons/Feather` 图标未正确加载react-native-vector-icons - Icons not loading correctly react-native-vector-icons 如何使用带有 react-native-vector-icons 的材质社区图标 - How to use material community icons with react-native-vector-icons react-native-vector-icons/react-native-elements 不起作用 - react-native-vector-icons/ react-native-elements not working 无法在零食 expo 中使用 react-native-vector-icons - unable to use react-native-vector-icons in snack expo React Native - 导入 @rneui(或 react-native-vector-icons)总是会产生错误并破坏安全区域的项目 - React Native - Importing @rneui (or react-native-vector-icons) always creates error and breaks projects with safe-area
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM