harmonyOS自定义Popup

第一步:自定义UI样式

 @State customPopup: boolean = false
  // popup构造器定义弹框内容
  @Builder
  popupBuilder() {
    Column({ space: 2 }) {
      Text("删除辅助安全域")
        .margin({ top: 15, left: 10 })
        .onClick(() => {
          this.customDialogController.open()
        })
      Text("清楚缓存")
        .margin({ top: 20, left: 10 })
        .onClick(() => {
          this.customDialogController.open()
        })
    }.width(200).height(100).padding(5)
    .alignItems(HorizontalAlign.Start)
  }

第二步:调用Popup

 Text("......")
          .height(50)
          .margin({ right: 50 })
          .onClick(() => {
            this.customPopup = !this.customPopup
          })
          .bindPopup(this.customPopup, {
            builder: this.popupBuilder, //气泡的内容
            placement: Placement.Bottom, //气泡的弹出位置
            popupColor: Color.Pink, //气泡的背景色
            onStateChange: (e) => {
              console.info(JSON.stringify(e.isVisible))
              if (!e.isVisible) {
                this.customPopup = false
              }
            }
          })

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值