如何在node.js中导入font-awesome以便在react.js中使用? [英] How to import font-awesome in node.js to use in react.js?
本文介绍了如何在node.js中导入font-awesome以便在react.js中使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用node.js和react.js. 我已经像这样导入了自己的css文件:
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'
然后它不起作用.
我做错什么了吗?还是有另一种方法?
Am I doing something wrong? Or is there maybe another way?
推荐答案
这是我完全在前端反应端完成的方式:
Here's how i did it entirely in the front end react side:
-
在
<head>
标签内添加超棒的字体
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">
npm install --save react-fontawesome
导入文件并将其用于您的React组件
Import the file and use it in your react components
import FontAwesome from 'react-fontawesome';
// ..rest of your code
<FontAwesome name="linkedin" size="2x"/>
这篇关于如何在node.js中导入font-awesome以便在react.js中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文