07-09 16:39:01.782 C015B0/xxxx/NETSTACK: [http_exec.cpp:499] taskid=-2147483551, size:90050, dns:4.813, connect:42.008, tls:54.322, firstSend:0.347, firstRecv:1537.666, total:1640.032... 07-09 16:39:01.997 A03D00/JSAPP I url:https://xxx.xxxx.com/xxx
@Entry
@Component
struct Index {
@State data: Array<number> = []
onPageShow(): void {
// 使用setTimeout模拟网络数据加载慢
setTimeout(() => {
this.data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}, 2000)
}
build() {
Column() {
Image($r('app.media.startIcon'))
.height(50)
.width(50)
Image($r('app.media.startIcon'))
.height(50)
.width(50)
List({ space: 10 }) {
ForEach(this.data, (item: number) => {
ListItem() {
Text(item.toString())
.height(30)
}
})
}
.alignListItem(ListItemAlign.Center)
}
.alignItems(HorizontalAlign.Center)
.justifyContent(FlexAlign.Center)
.height('100%')
}
} 优化数据加载时的显示效果。可以参考以下方案: