所以我刚刚发现了 Angular Material 。我想设置它,但是浏览器无法加载 Angular Material 主题。它给了我以下错误:
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
还有,
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:3200/node_modules/@angular/material/prebuilt-themes/indigo-pink.css".
首先,这是我的元素结构:
如您所见,我在 index.hbs 文件中添加了一个元素,其中包含指向 indigo-pink 主题的链接。在此之前,我尝试使用
将主题导入到公用文件夹中的 styles.css 文件中@import "~@angular/material/prebuilt-themes/indigo-pink.css";
两种方式最终都给我同样的上述错误。有人看到我做错了什么吗?
最佳答案
您绝对不能在 index.html 中引用 node_modules。 @import 将是正确的方法。看起来你使用的是 Webpack 而不是 Angular CLI,它会自动完成这项工作,所以你需要找到一个 Webpack 插件来处理 @import 并将样式捆绑在一起,或者如果你有一个,修复你的 webpack 配置。尝试:https://github.com/webpack-contrib/css-loader
关于javascript - 平均应用程序 : Can't find theme in Angular material,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49282802/