用Nativescript+Angular开发手机应用时,有时需要根据设备屏幕尺寸设置不同样式,可以采用一下方法:
testing.html:
<StackLayout [ngClass]="containerClass"> </StackLayout>
testing.component.ts:
get containerClass(): string {//cover IphoneXif (this._screenWidth <= 1125) {return 'container-750';} else {return 'container-1242'}}
testing.scss
.oontainer-750 {
}.oontainer-1242 {
}