Angular 2材质无法加载样式 [英] Angular 2 Material can't load style

查看:77
本文介绍了Angular 2材质无法加载样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用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,请遵循他们的

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材质无法加载样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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