导入主题的css无法解决材料错误

时间:2018-05-24 14:09:05

标签: angular-material

我在Angular 6应用程序中收到以下错误

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

我在app.component.css中导入了以下主题,但我仍然在浏览器的控制台上收到此错误

@import url("../../node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css");

1 个答案:

答案 0 :(得分:0)

请注意以下有关在guide中使用预建主题的声明:

  

如果您正在使用Angular CLI,这就像在styles.css文件中包含一行一样简单

您应该在应用程序的主样式表中使用import语句 - styles.css - 而不是app.component.css。另外,请注意指南中的另一个声明:

  

实际路径取决于您的服务器设置。