font-awesome 字体未加载到 angular 项目中 [英] font-awesome fonts are not loaded into angular project
问题描述
我已经使用 angular 5 一段时间了,但似乎我无法将任何字体很棒的图标加载到我构建的项目中.
I've been using angular 5 for a while now and it seems that I can't load any font-awesome icons into my built project.
我按照下面链接中提到的步骤进行了彻底的操作.https://www.npmjs.com/package/angular-font-awesome
I followed the steps thoroughly as mentioned in the link below. https://www.npmjs.com/package/angular-font-awesome
看起来 CSS 文件包含在项目中,但当我在浏览器开发者工具的网络部分检查时,它无法加载字体.
It appears that the CSS file is included in the project but it's not able to load the fonts as I checked in the network section of my browser's developer tools.
我在渲染页面中看到的只是方形图标,而不是字体很棒的图标.
All I'm seeing in the rendered page is square icons instead of font-awesome icons.
如果有人能帮我解决这个问题,我将不胜感激.
I would really appreciate it if anyone can help me with this.
推荐答案
使用
$ npm i font-awesome
打开你的 angular-cli.json
文件,搜索属性 styles
和 assets
,在其中添加:
Open your angular-cli.json
file, search for the properties styles
and assets
, add this in it :
// styles
"../node_modules/font-awesome/css/font-awesome.css"
// assets
"../node_modules/font-awesome/fonts"
(当然你也可以把字体复制到你自己的文件夹里).
(You can of course copy the fonts and put them into your own folder).
这篇关于font-awesome 字体未加载到 angular 项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!