示例如下:// xxx.ets @Entry @Component struct DoubleList { private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] @State canScroll: boolean = true build() { Column() { List({ space: 20, initialIndex: 0 }) { ForEach(this.arr, (item: number) => { ListItem() { Text(`${item}`) .width('100%') .height(200) .fontSize(16) .textAlign(TextAlign.Center) .borderRadius(10) .backgroundColor(0xFFFFFF) } ListItem() { Button(`${item}`).onClick(() => { }) } }, (item: string) => item) } .onClick(() => { console.log('click') }) .enabled(this.canScroll) .onDidScroll((scrollState: ScrollState) => { console.log('scroll') this.canScroll = false; }) } .width('100%') .height('100%') .backgroundColor(0xDCDCDC) .padding({ top: 5 }) } }
示例如下: