尝试这个
<div class="home-component"
[style.width.px]="width"
[style.height.px]="height">Some stuff in this div</div>
[更新]:设置使用百分比
[style.height.%]="height">Some stuff in this div</div>
在Angular 2中动态更新CSS
尝试这个
<div class="home-component"
[style.width.px]="width"
[style.height.px]="height">Some stuff in this div</div>
[更新]:设置使用百分比
[style.height.%]="height">Some stuff in this div</div>