如何在 Angular 中使用 FontAwesome 作为字体系列

How to use FontAwsome as a font-family in Angular

我想在我的 css 文件中使用 fontAwsome 作为 fontFamily,以便更改图标后的 <li>

在正常情况下 HTML/CSS 我可以毫无问题地这样做:

ul li:not(:last-child):after {
font-family: 'FontAwesome';
content: '\f105';
font-size: 13px;
top: 0px;
right: 0;
position: absolute;
}

但是 angular 我无法访问我的 css 文件中的 FontAwesome。

在我的组件 html 中,我使用它没有任何问题:<fa-icon icon="home"></fa-icon> .

  1. npm i font-awesome
  2. 在您的 css 中导入:@import "~font-awesome/css/font-awesome.css"
  3. 在你的html中,你只需要做这样的事情:<i class="fa fa-home"></i>