HarmonyOS Swiper循环问题

Swiper少于4个不能循环吗?看文档里面的demo,3个也可以循环的。实际使用中3个不能循环,设置了loop为true也没用。

HarmonyOS
2024-09-30 10:44:50
287浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

swiper的使用参考以下demo:

@Entry  
@Component  
struct SwiperExample {  
  private swiperController: SwiperController = new SwiperController()  
  build() {  
    Column({ space: 5 }) {  
      Swiper(this.swiperController) {  
        Text('0')  
          .width('90%')  
          .height('100%')  
          .backgroundColor(Color.Gray)  
          .textAlign(TextAlign.Center)  
          .fontSize(30)  
        Text('1')  
          .width('90%')  
          .height('100%')  
          .backgroundColor(Color.Green)  
          .textAlign(TextAlign.Center)  
          .fontSize(30)  
        Text('2')  
          .width('90%')  
          .height('100%')  
          .backgroundColor(Color.Pink)  
          .textAlign(TextAlign.Center)  
          .fontSize(30)  
      }  
      .loop(true)  
    }.width('100%')  
    .margin({ 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.

另外,swiper的使用也可参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-container-swiper-V5

将swiper的.nextMargin(this.bannerMargin)或者.prevMargin(this.bannerMargin)注释掉就可以正常循环了。

分享
微博
QQ
微信
回复
2024-09-30 16:45:27
相关问题
HarmonyOS 线程通信 事件循环问题
800浏览 • 1回复 待解决
HarmonyOS Swiper的disableSwipe问题
525浏览 • 1回复 待解决
HarmonyOS swiper + LazyForEach使用问题
1175浏览 • 1回复 待解决
如何排查循环引用的问题
1620浏览 • 1回复 待解决
HarmonyOS swiper数据刷新问题
657浏览 • 1回复 待解决
HarmonyOS Swiper+ForEach使用问题
1198浏览 • 1回复 待解决
HarmonyOS swiper组件的使用问题
1090浏览 • 1回复 待解决
HarmonyOS Swiper嵌套RichEditor的问题
581浏览 • 1回复 待解决
Axios与Log循环依赖问题
922浏览 • 1回复 待解决
HarmonyOS 关于Swiper指示器问题
1147浏览 • 1回复 待解决
HarmonyOS Tabs和Swiper联合使用问题
576浏览 • 1回复 待解决
HarmonyOS swiper修改指示器问题
541浏览 • 1回复 待解决
HarmonyOS forEach return退出循环
873浏览 • 1回复 待解决
HarmonyOS 无限循环banner效果
680浏览 • 1回复 待解决
HarmonyOS feature模块循环依赖
870浏览 • 1回复 待解决
HarmonyOS 循环水平滚动
449浏览 • 1回复 待解决