问题描述
我开始使用Angular Material库作为界面在Angular中开发一个Web应用程序.但是在尝试导入预建主题时出现错误.为了导入它,我在index.html
文件中添加了<link rel="stylesheet" href="../node_modules/@angular/material/prebuilt-themes/indigo-pink.css">
,但是当我运行ng serve
时却无法获取该文件.
I'm starting to develop an web app in Angular using the Angular Material library for the interface. But I'm getting an error when trying to import a prebuilt theme. In order to import it, I added <link rel="stylesheet" href="../node_modules/@angular/material/prebuilt-themes/indigo-pink.css">
to my index.html
file but when i run ng serve
I cannot get the file.
推荐答案
如果您使用的是angular-cli
,请遵循他们的包含Angular-Material的步骤.
If you are using angular-cli
follow their steps for including Angular-Material.
确保您在src/styles.css
@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';
@import '~https://fonts.googleapis.com/icon?family=Material+Icons';
与angular-material
在其自己的入门指南网站上提出的建议稍有不同,但这对我有用.
It's slightly different to what angular-material
suggest on their own Getting Started site but it worked for me.
这篇关于Angular 2材质无法加载样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!