待办事项:
- 基于子域加载的 css 文件。
例如:我有 abc.css、xyz.css,这些 css 应该基于子域加载,例如如果 abc 则必须加载 abc.css 等等。
试用案例:
- 从 angular-cli.json 动态加载 css(找不到方法来 动态加载)
- 在 index.html 上加载 css(遇到 MiME 类型问题)
- 在应用初始化时使用样式加载器,例如 require("style-loader!./style.css");
使用的版本: Angular 4.4.6 版本。
谁能帮我解决这个问题?
我愿意接受所有建议,请提出建议。
谢谢。
最佳答案
试试这个:
在 HTML 模板中:
<link rel="stylesheet" [href]="getCssUrl()">
在 component.ts 中:
constructor (private sanitizer: DomSanitizer) {}
getCssUrl() {
// Implement your code to return CSS url based on sub-domain
const cssURL = xxx;
return sanitizer.bypassSecurityTrustResourceUrl(cssUrl);
}
关于css - 基于子域在 Angular 应用程序上加载 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51759252/