如何在角度中包含材质图标库? [英] How to include material icon library in angular?

查看:57
本文介绍了如何在角度中包含材质图标库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我为此 https://github.com/angular/angular-cli/issues/2662 ),我将CSS添加到angular.json中,并导入库instyle.css(它给出了类似./src/styles.css的错误(./node_modules/raw-loader!./node_modules/postcss-loader/lib ??嵌入!./src/styles.css)),在本地项目中以角度安装材质图标库的正确方法是什么?

(i refer this link for that https://github.com/angular/angular-cli/issues/2662), I add CSS in angular.json and import library instyle.css (it gives an error like ./src/styles.css (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./src/styles.css)), what is the proper way to install material icon library in the local project in angular?

npm install material-design-icons-iconfont --save

angular.json

angular.json

"styles": [
  "src/styles.css",
  "../node_modules/material-design-icons/iconfont/material-icons.css",
],

style.css

style.css

@import "~material-design-icons-iconfont/dist/material-design-icons";

index.html

index.html

<link href="../material-design-icons-iconfont/dist/fonts/" rel="stylesheet">

推荐答案

使用此链接解决了我的问题( https://www.npmjs.com/package/material-icons )

using this link resolved my problem(https://www.npmjs.com/package/material-icons)

npm i material-icons

styles.css

styles.css

@import '~material-icons/iconfont/material-icons.css';

这篇关于如何在角度中包含材质图标库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆