我想在angular组件中使用来自cdn的样式表。样式应该只封装在该组件中。无法使用本机封装模式,因为ie不支持。
有什么建议吗?
发布于 2017-09-08 06:09:27
我不认为在你的组件模板中有好的方法可以做到这一点。我想说的是探索ngAfterViewInit
选项作为大多数外部的东西,一旦角度模板被复合,就被放置在组件的lyfe循环中。
@Component({selector: 'my-cmp', template: `...`})
class MyComponent implements AfterViewInit {
ngAfterViewInit() {
// executes after the view is loaded
}
}
如果你使用的是angular cli,你可以在你的cli文件中配置它们,但我认为你需要把它下载到你的资源路径中,并给出路径。我认为cli不会采用cdn路径。
//part of cli configuration
"prefix": "sd",
"styles": [
"../node_modules/bootstrap/scss/bootstrap.scss",
"../node_modules/font-awesome/scss/font-awesome.scss",
"../node_modules/primeng/resources/primeng.min.css",
"../node_modules/primeng/resources/themes/omega/theme.css",
"../node_modules/codemirror/lib/codemirror.css",
"styles.scss"
],
https://stackoverflow.com/questions/46101690
复制相似问题