[英]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=free在ReactJS 上,我可以使用取自此网站的名称来显示图标: 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:对于那些正在努力解决这个问题的人,只需将solid
或light
标签添加到您的组件中,它就会更改图标,例如:
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.