【发布时间】:2020-09-17 20:18:18
【问题描述】:
首先我无法通过 index.html 导入 css,并且出现 MIME 类型错误: enter image description here 拒绝应用来自 'http://localhost:4200/css/pink-bluegrey.css' 的样式,因为它的 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型,并且启用了严格的 MIME 检查。
如果我尝试通过 angular.json 导入它,那么我无法插入 ID 标签 id="themeAsset"。
我想添加 id 的原因是因为我想从 https://material.angular.io/guide/theming 执行此操作
函数 changeTheme(themeName) {
document.getElementById('themeAsset').href = /path/to/my/${themeName}.css;
}
所以我可以通过单击更改整个应用程序样式的样式,而不是向每个组件添加类
【问题讨论】:
-
这个我不能通过 index.html 插入