HarmonyOS bindSheet如何实现嵌套滚动关闭容器效果

HarmonyOS
2024-12-18 15:57:57
1030浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

请参考以下代码:

@Entry
@Component
struct SheetTransitionExample {
  @State isShow: boolean = false
  private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

  @Builder
  myBuilder() {
    Column() {
      List({ space: 20, initialIndex: 0 }) {
        ForEach(this.arr, (item: number) => {
          ListItem() {
            Text('' + item)
              .width('100%')
              .height(100)
              .fontSize(16)
              .textAlign(TextAlign.Center)
              .borderRadius(10)
              .backgroundColor(0xFFFFFF)
          }
        }, (item: string) => item)
      }
      .listDirection(Axis.Vertical)
      .width('90%')
    }
    .width('100%')
  }

  build() {
    Column() {
      Button("transition modal 1")
        .onClick(() => {
          this.isShow = true
        })
        .fontSize(20)
        .margin(10)
        .bindSheet($$this.isShow, this.myBuilder(), {
          detents: [SheetSize.LARGE],
          backgroundColor: Color.Gray,
          blurStyle: BlurStyle.Thick,
          showClose: true,
          title: { title: "title", subtitle: "subtitle" },
          preferType: SheetType.CENTER
        })
        .onDisAppear(() => {
          this.isShow = false
        })
    }
    .justifyContent(FlexAlign.Start)
    .width('100%')
    .height('100%')
  }
}
  • 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.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
分享
微博
QQ
微信
回复
2024-12-18 19:09:24
相关问题
如何实现嵌套滚动技术
2073浏览 • 1回复 待解决
HarmonyOS 如何实现滚动渐变效果
1067浏览 • 1回复 待解决
HarmonyOS 嵌套滚动冲突
869浏览 • 1回复 待解决
栅格布局怎么实现滚动效果
1467浏览 • 0回复 待解决
页面和列表嵌套滚动实现列表吸顶
2264浏览 • 1回复 待解决
是否可以实现滚动锚定的效果
1346浏览 • 1回复 待解决
HarmonyOS Web嵌套滚动体验差
816浏览 • 1回复 待解决
基于webView的嵌套滚动
1037浏览 • 1回复 待解决