可参考如下代码@Entry @Component struct ContactsList { @State list: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] @Builder itemHead(text: string) { Text(text) .fontSize(20) .backgroundColor(Color.Green) .width('100%') .padding(5) .textAlign(TextAlign.Center) } @Builder itemFoot(text: string) { Text(text) .fontSize(20) .backgroundColor(Color.Red) .width('100%') .padding(5) .textAlign(TextAlign.Center) } build() { List() { ListItemGroup({ header: this.itemHead('吸顶'), footer: this.itemFoot('吸底') }) { ForEach(this.list, (item: number) => { ListItem() { Column() { Text(item.toString()) .textAlign(TextAlign.Center).width('100%') }.height(100) } }) } }.sticky(StickyStyle.Footer) // 设置吸底 } }
可参考如下代码