配置angular使用Font Awesome

Include Font Awesome

包含 Font Awesome

Font Awesome gives you scalable vector icons that can instantly be customized — size, color, drop shadow, and anything that can be done with the power of CSS.
Font Awesome 为您提供可立即定制的可缩放矢量图标 - 尺寸,颜色,阴影以及任何可以通过CSS强大功能进行定制的图标。

Create a new project and navigate into the project...
创建一个新项目并导航到项目中...

ng new my-app
cd my-app

Install the font-awesome library and add the dependency to package.json...
安装font-awesome库并将依赖关系添加到package.json...

npm install --save font-awesome

Using CSS

使用 CSS

To add Font Awesome CSS icons to your app...
将Font Awesome CSS图标添加到您的应用程序...

// in angular.json
"build": {
  "options": {
    "styles": [
      "../node_modules/font-awesome/css/font-awesome.css"
      "styles.css"
    ],
  }
}

使用 SASS

Create an empty file _variables.scss in src/.
src/ 中创建一个空文件 _variables.scss

Add the following to _variables.scss:
将以下内容添加到 _variables.scss

$fa-font-path : '../node_modules/font-awesome/fonts';

In styles.scss add the following:
instles.scss 中添加如下内容:

@import 'variables';
@import '../node_modules/font-awesome/scss/font-awesome';

Test

测试

Run ng serve to run your application in develop mode, and navigate to http://localhost:4200.
运行 ng serve 以开发模式运行您的应用程序,并导航到 http//localhost:4200

To verify Font Awesome has been set up correctly, change src/app/app.component.html to the following...
要验证 Font Awesome 已正确设置,请将 src/app/app.component.html 更改为以下内容...

<h1>
  {{title}} <i class="fa fa-check"></i>
</h1>

After saving this file, return to the browser to see the Font Awesome icon next to the app title.
保存此文件后,返回到浏览器以查看应用标题旁边的 Font Awesome 图标。

More Info

更多信息

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 这次去日本是一次出差,也是我第一次去日本。早就想要去日本一次,很想去感受这个民族的素质,日本这个国家让我常听到的赞...
    马生角陈宾利阅读 11,725评论 2 7
  • 低着头,不说话,就这样不知道僵持了多久…… 我问,“还去吗?” 你说,“不去了,不想去。” 这是你第一次拒绝朋友的...
    熊猫微刊阅读 3,446评论 0 5
  • 南方人,小时候吃得最多的荤菜大约就是鱼了,而每个人小时候都一定有不少捕鱼的经历。 七十年代,物质匮乏,吃荤菜的机会...
    铁马老言阅读 3,593评论 2 5

友情链接更多精彩内容