NgStyle

修改 HTML 元素的样式。

Update an HTML element styles.

查看"说明"...

NgModule

选择器

属性

属性说明
@Input()
ngStyle: { [key: string]: string; }
Write-only.

说明

这些样式会根据表达式的求值结果进行更新:

The styles are updated according to the value of the expression evaluation:

  • key 是样式名,可以带一个可选的 .<unit> 后缀(比如 'top.px', 'font-style.em'),

    keys are style names with an optional .<unit> suffix (ie 'top.px', 'font-style.em'),

  • value 是一些与这些属性相关的值(以指定的单位表示)。

    values are the values assigned to those properties (expressed in the given unit).

<some-element [ngStyle]="{'font-style': styleExp}">...</some-element> <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element> <some-element [ngStyle]="objExp">...</some-element>
      
      <some-element [ngStyle]="{'font-style': styleExp}">...</some-element>

<some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>

<some-element [ngStyle]="objExp">...</some-element>
    

方法

ngDoCheck()
      
      ngDoCheck()
    
参数

没有参数。