HarmonyOS List如何渲染2倍的数据

不动数据源List如何渲染2倍的数据,就是传入的List数据为1,2,3,想要渲染出来的数据为:1,1,2,2,3,3。

HarmonyOS
2025-01-09 17:45:32
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Excelsior_abit

参考示例如下:

@Entry
@Component
struct ListDemo {
  @State arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

  build() {
    Column() {
      List({ space: 20 }) {
        ForEach(this.arr, (item: number) => {
          ListItem() {
            Text('' + item)
              .width('100%')
              .height(100)
              .fontSize(16)
              .textAlign(TextAlign.Center)
              .borderRadius(10)
              .backgroundColor(0xFFFFFF)
          }

          ListItem() {
            Text('' + item)
              .width('100%')
              .height(100)
              .fontSize(16)
              .textAlign(TextAlign.Center)
              .borderRadius(10)
              .backgroundColor(0xFFFFFF)
          }
        }, (item: string) => item)
      }
      .width('90%')
      .sticky(StickyStyle.None)
      .scrollBar(BarState.Off)
    }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 })
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
分享
微博
QQ
微信
回复
2025-01-09 19:26:20
相关问题
HarmonyOS 图片两图? 三
784浏览 • 1回复 待解决
HarmonyOS 界面数据渲染问题
888浏览 • 1回复 待解决
HarmonyOS SM2数据签名
634浏览 • 1回复 待解决
HarmonyOS List数据全显示
656浏览 • 1回复 待解决
HarmonyOS list数据加载问题
549浏览 • 1回复 待解决
HarmonyOS List怎么刷新数据
813浏览 • 1回复 待解决
HarmonyOS list数据刷新,头像闪烁
575浏览 • 1回复 待解决
HarmonyOS List嵌套不能同步数据
959浏览 • 1回复 待解决
HarmonyOS List组件数据更新错误
967浏览 • 0回复 待解决
快速预览通过网络数据渲染页面
1077浏览 • 1回复 待解决
HarmonyOS list组件数据显示错乱
591浏览 • 1回复 待解决