Angular + CSS 自定义属性语法

Angular + CSS Custom properties syntax

我使用 angular 9.1.6 为 public 回购做出了贡献,语法如下

<div [style.--color-success]="'green'" >This is a div</div>

我得到了这样的编译 html

<div style="--color-success:green" >This is a div</div>

已合并,现在我在当前项目中使用该组件 angular 9.1.0,我编译的 html 忽略了自定义属性,尽管它保留了样式属性

<div style>This is a div</div>

然后我尝试了这个语法

<div [style.--color-success]="'green'" style="--color-mid:orange">This is a div</div>

给出编译后的 html 使用一种语法而不使用另一种语法

<div style="--color-mid:orange" >This is a div</div>

是否有任何 angular 配置会阻止使用此语法?

看这里,似乎是针对 Angular 9 + Ivy 修复的 https://github.com/angular/angular/issues/9343#issuecomment-550572936