Angular:一个标签可以绑定多个 ngStyle 吗?
不可以。一个标签只能绑定一个 ngStyle 指令,但可以在 ngStyle 中定义多个样式属性。例如:
<div [ngStyle]="{'color': textColor, 'background-color': bgColor}">This is a div</div>
在这个例子中,ngStyle 绑定了两个样式属性:color 和 background-color。textColor 和 bgColor 是组件中定义的变量。
原文地址: https://www.cveoy.top/t/topic/mJcI 著作权归作者所有。请勿转载和采集!