简体   繁体   English

我正在尝试在我的反应应用程序中添加图标,但此方法不起作用需要帮助和指导

[英]I am trying to add icons in my react app but this method not working Need help and guidance

package.json file 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 component here i am trying to add social media icons: icontext 组件在这里我正在尝试添加社交媒体图标:

   import React from 'react'


const IconsText = () => {
  return (
   <div className="container-fluid bg-[#1d3943]">

   </div>

  )
}

export default IconsText

I don't know what i am doing wrong i tried add code but failed what should I do to add icons我不知道我做错了什么我尝试添加代码但失败了我应该怎么做才能添加图标

In order to add font-awesome icons you need to make sure you have installed it first.为了添加font-awesome icons ,您需要确保首先安装它。 Go to your project folder and execute the command npm install react-icons or yarn add react-icons . Go 到您的项目文件夹并执行命令npm install react-iconsyarn add react-icons Now in your component you should import the react-icons module like:现在在您的组件中,您应该导入react-icons模块,例如:

import * as aiicons from 'react-icons/ai'

react-icons has each folder corresponding to what you wanna use. react-icons的每个文件夹都与您要使用的内容相对应。 Hope this helps!希望这可以帮助!

Check out the font awesome guide on importing icons in react查看关于在反应中导入图标的字体真棒指南

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我正在尝试向我的 React 应用程序添加路由器 - I am trying to add a router to my react app 我需要帮助尝试在 React 游戏中连接我的不同组件 - I need help trying to connect my different components in a React game 我正在尝试在我的 React Hangman App 中为一组字母设置动画 - I am trying to animate an array of letters in my React Hangman App 我正在尝试在我的 React Native 应用程序中实现 Redux,因为教程使用 ReactDOM.render() 方法,但我似乎无法找到它, - I am trying to implement Redux to my React Native app, as tutorials use ReactDOM.render() method, and I cannot seem to locate it, 我需要帮助以使我的徽标和社交图标悬停 - I need help making my Logo and Social Icons nopin on hover 我试图了解为什么此JS代码段无法正常工作,可以使用一些可添加到WP中的指南 - I am trying to understand why this JS snippet isn't working, could use some guidance adding to WP 我需要帮助理解 React 应用程序中的 TypeError 吗? - I need help understanding a TypeError in a React app? 当我试图打开我的反应应用程序时,CMD 显示 npm 错误:说'npm err? 缺少脚本:开始'任何人都可以帮助我吗? - While i am trying to open my react app the CMD showing an npm err! Saying 'npm err! missing script:start' can anyone help me? 我需要指导来解决我的 JavaScript 问题 - I need guidance to solve my JavaScript problem 我正在尝试在 React 中创建一个盒子,但它不起作用 - I am trying to create a box in React, and it is not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM