#鸿蒙学习大百科#Swiper中的图片过大如何解决?

Swiper中的图片过大如何解决?

HarmonyOS
2024-09-27 10:11:44
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
努力向前进
@Entry
@Component
struct Index {
  @State breakPoint: string = 'sm'
  //根据断点来设置displayCount的数量
  build() {
    GridRow({ columns: { sm: 4, md: 8, lg: 12 } }) {
      GridCol({ span: { sm: 4, md: 8, lg: 12 } }) {
        Swiper() {
          Text().width("100%")
            .height(200)
            .backgroundColor(Color.Blue)
          Text().width("100%")
            .height(200)
            .backgroundColor(Color.Yellow)
          Text().width("100%")
            .height(200)
            .backgroundColor(Color.Pink)
        }.displayCount(this.breakPoint === "lg" ? 3 : 1) //根据尺寸设置展示item的数量

      }
      .height('100%')
      .width('100%')
    }.onBreakpointChange((breakpoint: string) => {
      this.breakPoint = breakpoint
    })

  }
}
  • 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.
分享
微博
QQ
微信
回复
2024-09-27 15:59:29
相关问题