代码之家  ›  专栏  ›  技术社区  ›  nachshon f

角度-在[ngStyle]中动态更改离子CSS属性

  •  0
  • nachshon f  · 技术社区  · 6 年前

    我想用 [ngClass] 动态更改 --bullet-background-active 颜色 Ionic Slide 基于此 article .

    <ion-slides pager="true" [ngStyle]="{'--bullet-background-active':BulletColorVar}">
    

    然而,它似乎并不特别适用于Ionic定制CSS属性。

    有没有办法解决这个问题?

    0 回复  |  直到 6 年前
        1
  •  0
  •   EJ Sulit    5 年前

    尝试使用 style.setProperty(propertyName, value, priority) 作用

    CSS

    ion-slides {
       --bullet-background-active: --bullet-color-var
    }
    

    TS

    document.body.style.setProperty('--bullet-color-var', BulletColorVar)