[英]Use stylesheet from cdn inside angular 2 component
我想使用角度組件內cdn的樣式表。 樣式應僅封裝在該組件內。 無法使用本機封裝模式,因為它不支持。
有什么建議嗎?
我認為您無法在組件模板中實現此目的。 我會說要探索ngAfterViewInit
選項,因為它是大多數外部事物,並且一旦編譯了angulat模板,就會將其放置在組件的lyfe循環中。
@Component({selector: 'my-cmp', template: `...`})
class MyComponent implements AfterViewInit {
ngAfterViewInit() {
// executes after the view is loaded
}
}
如果您使用的是角度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"
],
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.