如何使用 fontawesome JS API 只导入一些图标?
我完整阅读了文档。
我安装了 NPM 依赖项,然后在我的 index.js
中:
import { library, icon } from '@fortawesome/fontawesome-svg-core'
import { faPlus } from '@fortawesome/free-solid-svg-icons'
library.add(faPlus)
在我的 HTML 中
<i class="fa-solid fa-plus"></i>
但图标未呈现。
我缺少什么?我正在使用 webpack 5。
I fully read the docs.
I installed NPM dependencies and then in my index.js
:
import { library, icon } from '@fortawesome/fontawesome-svg-core'
import { faPlus } from '@fortawesome/free-solid-svg-icons'
library.add(faPlus)
And in my HTML
<i class="fa-solid fa-plus"></i>
But the icon is not rendered.
What am I missing? I am using webpack 5.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在
使用dom.watch()
之前需要导入dom
You need to import
dom
beforeuse dom.watch()
我缺少
dom.watch()
他们在文档中没有提及。现在它可以工作了,而且包的大小要小得多。
I was missing
dom.watch()
They don't mention in the docs. Now it's working and the bundle size is much lower.