[英]I am trying to add icons in my react app but this method not working Need help and guidance
package.json文件
{
"name": "myapp",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.2.0",
"@fortawesome/free-regular-svg-icons": "^6.2.0",
"@fortawesome/free-solid-svg-icons": "^6.2.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.4.0"
},
"devDependencies": {
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@vitejs/plugin-react": "^2.1.0",
"autoprefixer": "^10.4.12",
"postcss": "^8.4.16",
"tailwindcss": "^3.1.8",
"vite": "^3.1.0"
}
}
icontext 組件在這里我正在嘗試添加社交媒體圖標:
import React from 'react'
const IconsText = () => {
return (
<div className="container-fluid bg-[#1d3943]">
</div>
)
}
export default IconsText
我不知道我做錯了什么我嘗試添加代碼但失敗了我應該怎么做才能添加圖標
為了添加font-awesome icons
,您需要確保首先安裝它。 Go 到您的項目文件夾並執行命令npm install react-icons
或yarn add react-icons
。 現在在您的組件中,您應該導入react-icons
模塊,例如:
import * as aiicons from 'react-icons/ai'
react-icons
的每個文件夾都與您要使用的內容相對應。 希望這可以幫助!
查看關於在反應中導入圖標的字體真棒指南
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.