进口字体很棒的图标,其名称具有破折号(“ - ”)

发布于 2025-01-23 04:01:30 字数 1091 浏览 2 评论 0原文

我正在使用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 get this error:
portfolio importing error

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦萦几度 2025-01-30 04:01:30

这是问题!

您正在尝试使用Pro图标 - 它在免费图标包中不存在。

(编辑:对于将来的参考,调试此类导入问题的一种好方法是cd @fortawesome 目录中的目录,然后使用< https://github.com/junegunn/fzf 寻找您要寻找的文件在意识到图标中不存在免费版本之前。)

Here's the problem!

enter image description here

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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文