caohuahui

头图卡宽高比例计算

@@ -39,7 +39,19 @@ export struct HeadPictureCardComponent { @@ -39,7 +39,19 @@ export struct HeadPictureCardComponent {
39 } 39 }
40 .alignContent(Alignment.Bottom) 40 .alignContent(Alignment.Bottom)
41 .width(CommonConstants.FULL_WIDTH) 41 .width(CommonConstants.FULL_WIDTH)
  42 + .aspectRatio(imageSizeRatio(this.compDTO.operDataList[0].coverSize))
42 .height(200) 43 .height(200)
43 } 44 }
44 } 45 }
45 46
  47 +function imageSizeRatio(size: string): number {
  48 + if (size != null) {
  49 + let parts: string[] = size.split("*");
  50 + let f = Number(parts[0])
  51 + let s = Number(parts[1])
  52 + return f / s;
  53 + } else {
  54 + return 1.0
  55 + }
  56 +}
  57 +