可以设置loop为true就可以开启无限轮播,参考文档https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-container-swiper-V5\#loop参考democonst swiperImage: Resource[] = [ $r('app.media.ic_banner01'), $r('app.media.ic_banner02')] @Entry @Component struct Index { build() { RelativeContainer() { Swiper() { ForEach(swiperImage, (item: Resource) => { Image(item) .width('100%') .aspectRatio(2.25) .borderRadius(16) .backgroundColor(Color.White) }, (item: Resource) => JSON.stringify(item)) } .loop(true) .interval(2000) .itemSpace(0) .width('100%') .indicator(new DotIndicator().selectedColor('#F74E42')) .displayCount(1) .autoPlay(true) .margin({ top: 12, bottom: 12 }) } .height('100%') .width('100%') .backgroundColor(Color.Gray) } }
可以设置loop为true就可以开启无限轮播,参考文档
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-container-swiper-V5\#loop
参考demo