进口字体很棒的图标,其名称具有破折号(“ - ”)
我正在使用React.js创建一个投资组合网站。我决定使用字体很棒的图标,因为我喜欢它们的外观。但是,当我去导入任何名称中具有破折号的图标时,我不知道如何导入它。这是我到目前为止的代码(用于导入):
import "font-awesome/css/font-awesome.min.css";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
// All these are single name icons
import {faPython} from "@fortawesome/free-brands-svg-icons/faPython";
import {faJs} from "@fortawesome/free-brands-svg-icons/faJs";
import {faReact} from "@fortawesome/free-brands-svg-icons/faReact";
import {faCuttlefish} from "@fortawesome/free-brands-svg-icons/faCuttlefish";
// This one is named "rectangle-code"
import {faRectangleCode} from "@fortawesome/free-solid-svg-icons/faRectangleCode";
我无法使用名称中的破折号导入它,那么如何在没有任何错误的情况下导入此图标?
编辑:单击在这里在font Awesome网站上查看图标
I am using React.js to make a portfolio website. I decided to go with Font Awesome icons since I love the look of them. However when I go to import any icon that has that dash in the name, I can't figure out how to import it. Here's my code so far (for importing):
import "font-awesome/css/font-awesome.min.css";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
// All these are single name icons
import {faPython} from "@fortawesome/free-brands-svg-icons/faPython";
import {faJs} from "@fortawesome/free-brands-svg-icons/faJs";
import {faReact} from "@fortawesome/free-brands-svg-icons/faReact";
import {faCuttlefish} from "@fortawesome/free-brands-svg-icons/faCuttlefish";
// This one is named "rectangle-code"
import {faRectangleCode} from "@fortawesome/free-solid-svg-icons/faRectangleCode";
I can't import it using dashes in the name, so how do I import this icon without any errors?
EDIT: Click here to view the icon on Font Awesome's website
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是问题!
您正在尝试使用Pro图标 - 它在免费图标包中不存在。
(编辑:对于将来的参考,调试此类导入问题的一种好方法是
cd
@fortawesome 目录中的目录,然后使用< https://github.com/junegunn/fzf 寻找您要寻找的文件在意识到图标中不存在免费版本之前。)Here's the problem!
You're attempting to use a pro icon - it doesn't exist in the free icon packs.
(Edit: for future reference, a good way to debug import problems like this is to
cd
inside the@fortawesome
directory in your terminal, and then use something like https://github.com/junegunn/fzf to look for the file you're looking for. That's what I did before realizing the icon doesn't exist in the free version.)