角材料-拒绝应用样式

时间:2018-07-25 09:22:49

标签: css angular angular-material-5

我想使用角度材质,但是在导入角度材质主题css文件时遇到了问题- 我进口了 <link href="../node_modules/@angular/material/prebuilt-themes/indigo-pink.css" rel="stylesheet">中的index.html,但出现此错误=>

  

出现以下错误-    'http://localhost:8081/node_modules/@angular/material/prebuilt-themes/indigo-pink.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

请问如何使它工作? 我没有angular.jsonangular-cli.json

1 个答案:

答案 0 :(得分:1)

请参阅Docs,其中有具体的入门步骤,

第4步(来自材料文档),

  

第4步:添加主题

Including a theme is required to apply all of the core and theme styles to your application.

To get started with a prebuilt theme, include one of Angular Material's prebuilt themes globally in your application. 
  

如果使用的是Angular CLI,则可以将其添加到 styles.css styles.scss

@import "~@angular/material/prebuilt-themes/indigo-pink.css";