[英]How to display Fontawesome icons using Unicode and React?
I'm experimenting with React and want to display a list of Fontawesome icons.我正在尝试使用 React,并希望显示一个 Fontawesome 图标列表。
I have a JSON file that has the data set about as such:我有一个 JSON 文件,其中包含以下数据集:
{
"icons": [
{
"name": "Glass",
"id": "glass",
"unicode": "f000",
"created": 1,
"filter": [
"martini",
"drink",
"bar",
"alcohol",
"liquor"
],
"categories": [
"Web Application Icons"
]
},
etc
I can iterate through this and return and print each point of data, but can't figure out how to display the actual icons.我可以遍历它并返回并打印每个数据点,但无法弄清楚如何显示实际图标。
I have tried using unicode as such:我曾尝试使用 unicode :
return(
<div>
<ul>
<li>
<span>{data.name}</span>
<i className="fa">{data.unicode}</i>
</li>
</ul>
</div>
)
But it just prints the unicode value.但它只打印 unicode 值。
Would anyone know if it's possible to render the icon this way?有谁知道是否可以以这种方式呈现图标?
Convert the number to a string first, by calling String.fromCharCode
.首先通过调用
String.fromCharCode
将数字转换为字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.