这是一个示例代码:
component.ts文件
getThirty() {
return 'width:30%'
}
html文件
<div class="progress-bar" style = "getThirty()">
这不起作用...如何将函数绑定到输入?
我也试过[style]="getThirty()"
,但这仍然不起作用..
请帮忙!谢谢!
答案 0 :(得分:0)
我尝试使用以下方法,它适用于我。
<div class="col-md-2" style="{{getThirty()}}">
fhyjhrtjrjrj
</div>
希望这有助于。
答案 1 :(得分:0)
您可以按照以下方式执行此操作
<div [style.width]="getThirty">
2.在您的组件中:public getThirty = 30 +&#39;%&#39;;
它是:)