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

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

问题描述

我开始在 Angular 中使用界面的 Angular Material 库开发 Web 应用程序.但是在尝试导入预建主题时出现错误.为了导入它,我将 <link rel="stylesheet" href="../node_modules/@angular/material/prebuilt-themes/indigo-pink.css"> 添加到我的index.html 文件,但是当我运行 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 Material 无法加载样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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