[英]Angular renderer setStyle will not apply linear-gradient
Angular 的 renderer2 不會應用線性漸變 CSS。 誰能看到我錯過了什么?
export class AppComponent implements OnInit {
constructor(private renderer: Renderer2, private elementRef: ElementRef) {}
public ngOnInit(): void {
this.renderer.setStyle(
this.elementRef.nativeElement,
"background",
"linear-gradient(rgba(253,92,99,1), rgba(144,255,0,1) 30%);"
// "red" // works, so does this rule in CSS
);
}
}
這是一個stackblitz repro
本,
漸變規則中的最后一個分號會產生錯誤:這樣工作:
this.renderer.setStyle(
this.elementRef.nativeElement,
"background",
"linear-gradient(rgba(253,92,99,1), rgba(144,255,0,1) 30%)" //no semicolon in the end
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.