caohuahui

代码优化

... ... @@ -7,14 +7,21 @@ import { CompUtils } from '../../utils/CompUtils';
@Component
export struct HeadPictureCardComponent {
@State compDTO: CompDTO = {} as CompDTO
private item: ContentDTO
aboutToAppear() {
// Data Initialization.
this.item = this.compDTO.operDataList[0];
}
build() {
Stack() {
Image(this.compDTO.operDataList[0].coverUrl)
Image(this.item.coverUrl)
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
if (this.compDTO.operDataList[0].newsTitle != null) {
if (this.item.newsTitle != null) {
Row()
.width(CommonConstants.FULL_WIDTH)
.height(59)
... ... @@ -24,7 +31,7 @@ export struct HeadPictureCardComponent {
]
})
Row() {
Text(this.compDTO.operDataList[0].newsTitle)
Text(this.item.newsTitle)
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
.fontColor(Color.White)
... ... @@ -39,7 +46,7 @@ export struct HeadPictureCardComponent {
}
.alignContent(Alignment.Bottom)
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(imageSizeRatio(this.compDTO.operDataList[0].coverSize))
.aspectRatio(imageSizeRatio(this.item.coverSize))
.height(200)
}
}
... ...