我正在使用Angular 2+和Angular CLI。
如何在我的项目中添加超棒的字体?
在Angular 2.0最终版本发布后,Angular2 CLI项目的结构已更改 -您不需要任何供应商文件,不需要system.js-仅Webpack。所以你也是:
npm install font-awesome --save
在angular-cli.json
文件中找到styles[]
数组,并在此处添加“真棒字体”引用目录,如下所示:
"apps": [
{
"root": "src",
"outDir": "dist",
....
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.css",
"../node_modules/font-awesome/css/font-awesome.css" // -here webpack will automatically build a link css element out of this!?
],
...
}
]
],
在Angular的最新版本中,请改用
angular.json
文件,而不要使用../
。例如,使用"node_modules/font-awesome/css/font-awesome.css"
。
在您想要的任何html文件中放置一些超棒的字体图标:
<i class="fa fa-american-sign-language-interpreting fa-5x" aria-hidden="true"> </i>
停止应用程序Ctrl+,c然后使用重新运行应用程序,ng serve
因为观察者仅用于src文件夹,而未观察到angular-cli.json的更改。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句