代码如下:
Stack({alignContent:Alignment.TopStart}) {
Image(this.model.background?.length?this.model.background:$r('app.media.update_app_dialog_bg'))
.objectFit(ImageFit.Contain)
Column() {
// Text(this.model.content)
Text('薪资打卡机打卡机打啊打卡机打卡机打卡啊打卡机打卡机打卡卡机打卡机可大可久打卡机打交道打卡机卡就打卡机打卡机打卡机的就打卡机打卡薪资打卡机打卡机打卡机打卡机可大可就打卡机打卡机打卡机的就打卡机打卡薪资打卡机打卡机打卡机打卡机可大可久打卡机打交道打卡机卡就打卡机打卡机打卡机的就打卡机打卡薪资打卡机打卡机打卡机打卡机可大可久打卡机打交道打卡机卡就打卡机打卡机打卡机的就打卡机打卡薪资打卡机打卡机打卡机打卡机可大可久打卡机打交道打卡机卡就机的就打卡机打卡薪资')
.fontSize(14)
.fontColor('#4e4852')
.fontWeight(FontWeight.Regular)
.margin({
top:selfLpx(174),
bottom:selfLpx(10),
left:selfLpx(26),
right:selfLpx(29)
})
.textOverflow({ overflow: TextOverflow.Ellipsis })
.wordBreak(WordBreak.NORMAL)
.backgroundColor(Color.Pink)
.constraintSize({maxHeight: selfLpx(453-174-29-40.5-10)})
Blank().layoutWeight(1)
Row() {
Image(this.model.ignoreButtonImg?.length?this.model.ignoreButtonImg:$r('app.media.update_app_btn_no'))
.height(selfLpx(40.5))
.width(selfLpx((375-37*2-19*2-8)/2))
.margin({
bottom:selfLpx(29),
right:selfLpx(8)
})
.onClick(()=>{ // 取消
this.controller.close()
})
Image(this.model.updateButtonImg?.length?this.model.updateButtonImg:$r('app.media.update_app_btn_now'))
.height(selfLpx(40.5))
.width(selfLpx((375-37*2-19*2-8)/2))
.margin({
bottom:selfLpx(29)
})
.onClick(()=>{ // 更新
})
}.justifyContent(FlexAlign.SpaceBetween)
.width('100%')
.padding({
left:selfLpx(19),
right:selfLpx(19)
})
}
}
.width(selfLpx(300))
.height(selfLpx(453))
可以参考
结合textOverflow属性来处理文本超长的情况。textOverflow属性可以设置文本超长时的显示方式,例如截断、省略号等。需要注意的是,textOverflow属性需要配合maxLines一起使用,单独设置不生效