angular - 我可以在 Ionic 4 中动态更改 ion-item 自定义 css 属性 --background 吗?
问题描述
我们如何设置动态背景颜色?我需要基于数组渲染 ion-item 元素。我需要在 ngFor 循环中设置背景颜色,来自数组中的每个值。有任何想法吗?
我试过这样的事情。但它不起作用
<ion-list *ngFor="let shift of shifts">
<ion-item [style.--background]="'shift.color'">{{ shift.color }} qwe</ion-item>
</ion-list>
解决方案
尝试这个,
<ion-list *ngFor="let shift of shifts">
<ion-item [style.background]="shift.color"> {{shift.color}} qwe</ion-item>
</ion-list>
推荐阅读
- sql - 如何将 XML 转换为 SQL 表变量
- python - Django 通道套接字未连接到消费者
- bash - 回显包含美元的字符串变量的内容
- r - 绘制柱形图时如何避免重复分类变量?
- c# - 使用 WarpAffine() 将 Emgu.CV.Image 向右移动
- python - Pyomo:创建抽象模型和 AMPL 数据
- python - 两个数据之间的差异计算
- sql-server - SQL:我想解决,如何返回每个成员的最后一个操作
- mapbox - Mapbox iOS - 使用 centerOffset 时,不可见的注释显示在左上角
- spring-boot - 有没有办法在 Junit4(5) 中强制执行测试类的顺序