【问题标题】:Inline style interpolation not working angular9 [duplicate]内联样式插值不起作用angular9 [重复]
【发布时间】:2021-10-06 07:53:53
【问题描述】:

我想将我的组件属性值传递给内联 css。

<div [ngStyle]="{ 'width': '{{ object.value }}%' }">

该方法不起作用并出现错误:-

 Parser Error: Got interpolation ({{}}) where expression was expected

【问题讨论】:

  • 没有 {{ 和 }} 只是 [ngStyle]="{ 'width': object.value + '%' }"

标签: css interpolation angular9 inline-styles


【解决方案1】:

您的语法错误。使用以下语法之一

[style.width.%]="object.value"

或者

[ngStyle]="{ 'width.%': object.value }"

【讨论】:

    猜你喜欢
    • 2018-02-15
    • 1970-01-01
    • 2017-10-21
    • 1970-01-01
    • 1970-01-01
    • 2018-07-05
    • 2017-12-19
    • 1970-01-01
    • 2014-10-14
    相关资源
    最近更新 更多