【问题标题】:Pass style from string format HTML从字符串格式 HTML 传递样式
【发布时间】:2021-08-09 17:30:58
【问题描述】:

我想在[[ style="width:{{item.number}}" ]]中传递参数

请不要 DOM

【问题讨论】:

    标签: html angular styles progress-bar


    【解决方案1】:
                <div
                        class="progress-bar bg-danger"
                        role="progressbar"
                        style="width:50%"
                        aria-valuenow="50"
                        aria-valuemin="0"
                        aria-valuemax="100"
                ></div>
    

    【讨论】:

      【解决方案2】:

      你可以像这样用 ngStyle 做到这一点:

      &lt;div [ngStyle]="{'width.px': someVariable }"&gt;&lt;/div&gt;

      【讨论】:

      • 它的工作。但我将代码更改为 style.width ="{{ item.value}}%" 。相同的值。非常感谢您的回答。
      【解决方案3】:
      style.width ="{{ customer.type_value }}%"
      

      【讨论】:

        猜你喜欢
        • 2022-01-22
        • 2019-03-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多