如何获得角度为5的元素的全宽,而不仅仅计算?现在我只得到客户端的宽度而不是元素的整个宽度。
这段代码出了什么问题?
@ViewChild('box') box: ElementRef;
...
this.boxWidth = this.box.nativeElement.clientWidth;
HTML
<ion-row nowrap class="time-bar" [ngStyle]="{'left': leftscroll}" #box>
<p *ngFor="let i of day">{{i}}</p>
</ion-row>
使用offsetWidth。它还包括边框宽度
@ViewChild('box') box: ElementRef;
this.boxWidth = this.box.nativeElement.offsetWidth;