简体   繁体   English

vector-icons/FontAwesome5 在 react-native 上显示错误的图标

[英]vector-icons/FontAwesome5 showing wrong icon on react-native

On ReactJS I can show the icon by using it's name taken from this website: https://fontawesome.com/icons?d=gallery&q=eye&m=freeReactJS 上,我可以使用取自此网站的名称来显示图标: https://fontawesome.com/icons?d=gallery&q=eye&m=free

As you can see, if you search by eye, you'll have a lot of options there, and if you click on the icon it will show you what name you should use to call that icon.如您所见,如果您用眼睛搜索,那里会有很多选项,如果您单击图标,它将显示您应该使用什么名称来调用该图标。 For example: fas fa-eye will render a solid eye and far fa-eye will render a regular eye.例如: fas fa-eye将渲染一个实心的眼睛,而far fa-eye将渲染一个普通的眼睛。

The problem is that on react-native I can't call the icon name like this, it won't accept, so I have to just use the word eye , but this limits me by a random eye that's not from my choice.问题是在react-native上我不能这样称呼图标名称,它不会接受,所以我只能使用eye一词,但这限制了我的随机眼睛,这不是我的选择。 So I wanna know if there's any way that I can pick the icon that I want just like in ReactJS?所以我想知道是否有任何方法可以选择我想要的图标,就像在 ReactJS 中一样? This is how I'm currently using the fontawesome icons on react-native:这就是我目前在 react-native 上使用 fontawesome 图标的方式:

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

...

return <FontAwesome name={'eye} style={props.customStyle} />


The showed icon appears on the website's list, but as I said, there's more than one icon with the same name and I want be able to choose bettween then.显示的图标出现在网站的列表中,但正如我所说,有多个具有相同名称的图标,我希望能够在两者之间进行选择。

For those that are struggling into this problem, just add the solid or light tag into your component and it will change the icon, example:对于那些正在努力解决这个问题的人,只需将solidlight标签添加到您的组件中,它就会更改图标,例如:

return <FontAwesome name={'eye'} style={props.customStyle} solid />

you can try to use IconDefinition and choose icons by their names.您可以尝试使用IconDefinition并按名称选择图标。

import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome";
import { faBookOpen } from "@fortawesome/free-solid-svg-icons";
  
        <FontAwesomeIcon
            icon={faBookOpen}
            size={28}
          />

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

相关问题 反应本机! @expo/vector-icons/Fontisno 的问题 - React-native! Problem with @expo/vector-icons/Fontisno react-native 纸按钮矢量图标向右浮动 - react-native paper button vector-icons float right 在 React Native 中调整图标 FontAwesome5 的大小 - Resize Icon FontAwesome5 in React Native React-native fontawesome 一些图标没有显示 - React-native fontawesome some icons are not showing 尝试在 vanilla React Native 项目中解决 @expo/vector-icons/FontAwesome 时出错 - Error trying to resolve @expo/vector-icons/FontAwesome in a vanilla React Native project 如何在 React Native 中使用同名的 FontAwesome5 图标 - how to use FontAwesome5 icons with same name in react native 导入&#39;react-native-vector-icon&#39; 结果&#39;无法解析模块&#39;@expo/vector-icons&#39; 错误 - Importing 'react-native-vector-icon' results 'Unable to resolve module '@expo/vector-icons' error 反应原生矢量图标/fontawesome 未在 expo cli 中显示图标 - react native vector icons/fontawesome not showing icons in expo cli React Native - 图标名称的 expo/vector-icons typescript 类型定义 - React Native - expo/vector-icons typescript type definition for icon name BottomNavigation在React Native中不显示@ expo / vector-icons - BottomNavigation does not show @expo/vector-icons in React Native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM