为什么我的fontawesome偶像在我的下一个项目中呈现?
我有一个下一个项目。
但是,图标并未显示在网页上。我什至在“检查元素”和“父级”中检查了,图标元素不存在。
以下是我的_app.js文件:
import '../styles/globals.css'
import { config } from '@fortawesome/fontawesome-svg-core'
import '@fortawesome/fontawesome-svg-core/styles.css'
config.autoAddCss = false
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}
export default MyApp
下面是我的index.js文件,在页面目录中:
import React, { Fragment } from "react"
import Head from 'next/head'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import '../node_modules/@fortawesome/fontawesome-svg-core/styles.css'
export default function Home() {
return (
<Fragment>
<FontAwesomeIcon icon="fa-brands fa-facebook-f" />
</Fragment>
)
}
为什么我的图标渲染不进行以及如何修复? 提前致谢。
I have a Next.js project where I am using fontawesome icons.
However, the icon does not show up on the web page. I even checked under inspect element and in the parent div and the icon element is not there.
Below is my _app.js file:
import '../styles/globals.css'
import { config } from '@fortawesome/fontawesome-svg-core'
import '@fortawesome/fontawesome-svg-core/styles.css'
config.autoAddCss = false
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}
export default MyApp
And below is my index.js file in the pages directory:
import React, { Fragment } from "react"
import Head from 'next/head'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import '../node_modules/@fortawesome/fontawesome-svg-core/styles.css'
export default function Home() {
return (
<Fragment>
<FontAwesomeIcon icon="fa-brands fa-facebook-f" />
</Fragment>
)
}
Why isn't my icon rendering and how do I fix it?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您仍然需要将图标导入您的项目。这就是为什么什么都没有显示。这是您的
index.js
如果使用免费品牌SVG图标:You still need to import icons into your project. That's why there is nothing showing. This is what your
index.js
should look like if using the free brands svg icons: