Angular 渲染器 setStyle 将不会应用线性渐变
Angular renderer setStyle will not apply linear-gradient
Angular 的渲染器 2 不会应用线性渐变 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复制
本,
梯度规则中的最后一个分号产生错误:
这样就可以了:
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
);
Angular 的渲染器 2 不会应用线性渐变 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复制
本,
梯度规则中的最后一个分号产生错误: 这样就可以了:
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
);