代码如下:
@Entry
@Component
struct Test {
build() {
Stack() {
Row(){
Text('安徽省合肥市蜀山区金寨路189号(中国科大东区地铁站1号口步行470米)')
.width('100%')
.height(20)
.textOverflow({overflow:TextOverflow.Ellipsis})
}
.width('100%')
.padding(10)
}
.width('100%')
.height('100%')
}
}
请搭配maxLines来使用,参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-text-V5\#maxlines
demo: