角度 cli 中角度材料 2 的问题 [英] Issue with angular material 2 in angular cli

查看:42
本文介绍了角度 cli 中角度材料 2 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 angular material2 添加到我的项目中.(我使用 angular-cli)但是,当我运行 ng serve 时出现以下错误:

I am trying to add angular material2 to my project. (I use angular-cli) However, I get the following error when I run ng serve:

material.es5.js:177 找不到 Angular Material 核心主题.大多数 Material 组件可能无法按预期工作.有关更多信息,请参阅主题指南:https://material.angular.io/guide/theming

material.es5.js:177 Could not find Angular Material core theme. Most Material components may not work as expected. For more info refer to the theming guide: https://material.angular.io/guide/theming

虽然我将它添加到我的全局样式文件中.

Although I added it to my global style file.

@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';

我该如何解决?谢谢.

推荐答案

在你的 angular-cli.json 下:

"apps": [

  //....

"styles": [

   //... , 

  "../node_modules/@angular/material/prebuilt-themes/indigo-pink.css" //<--add this
  ],
]

这篇关于角度 cli 中角度材料 2 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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