问题
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:
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">
Install react-fontawesome
npm install --save react-fontawesome
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