How to import font-awesome in node.js to use in react.js?

瘦欲@ 提交于 2019-12-11 03:17:47

问题


I am working with node.js and react.js. I already imported my own css file like so:

import React from 'react';
import Modal from 'react-modal';
import './../App.css';

this works fine, but when I try to add font-awesome like so:

import './src/font-awesome-4.7.0/css/font-awesome.css'

then it doesn't work.

Am I doing something wrong? Or is there maybe another way?


回答1:


Here's how i did it entirely in the front end react side:

  1. Include font awesome inside the <head> tag

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    
  2. Install react-fontawesome

    npm install --save react-fontawesome

  3. Import the file and use it in your react components

    import FontAwesome from 'react-fontawesome';
    
    // ..rest of your code
    <FontAwesome name="linkedin" size="2x"/>
    


来源:https://stackoverflow.com/questions/44680038/how-to-import-font-awesome-in-node-js-to-use-in-react-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!