【问题标题】:Angular Material - Refused to apply styleAngular Material - 拒绝应用样式
【发布时间】:2018-07-25 09:22:49
【问题描述】:

我想使用角度材质,但在导入角度材质主题 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

【问题讨论】:

标签: css angular angular-material-5


【解决方案1】:

请参考Docs有具体的上手步骤,

第 4 步来自 Material Doc,

第 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.cssstyles.scss

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

【讨论】:

  • 我遵循了材料文档,但它确实不起作用:/我遇到了上述错误
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-01-27
  • 2023-03-22
  • 2018-07-15
  • 1970-01-01
  • 2019-04-11
  • 2018-12-19
  • 2018-11-15
相关资源
最近更新 更多