鸿蒙OS promptAction的使用

复制代码
效果如下:
复制代码
import { promptAction } from '@kit.ArkUI'

let customDialogId: number = 0

@Builder
function customDialogBuilder() {
  Column() {
    Blank().height(30)
    Text('确定要删除吗?').fontSize(15)
    Blank().height(40)
    Row() {
        Button("取消").onClick(() => {
          promptAction.closeCustomDialog(customDialogId)
        })
        .width(80).height(30)
        .fontColor($r("app.color.btn_button"))
        .backgroundColor($r('app.color.white'))
      Blank().width(50)
      Button("确认").onClick(() => {
        promptAction.closeCustomDialog(customDialogId)
      })
        .backgroundColor($r("app.color.btn_button"))
        .fontColor($r('app.color.white'))
     .width(80).height(30)
    }
  }
}



@Entry
@Component
struct CustomDialog {
  @State message: string = 'Hello World'

  @Builder
  customDialogComponent() {
    customDialogBuilder()
  }

  build() {
    Row() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
          .onClick(() => {
            promptAction.openCustomDialog({
              builder: () => {
                this.customDialogComponent()
              },
              showInSubWindow: false,
              offset: { dx: 5, dy: 5 },
              backgroundColor: 0xd9ffffff,
              cornerRadius: 20,
              width: '80%',
              height: 150,
              borderWidth: 1,
              borderColor:$r('app.color.white'), //使用borderColor属性,需要和borderWidth属性一起使用
              shadow: ({
                radius: 20,
                color: Color.Grey,
                offsetX: 50,
                offsetY: 0
              }),
            }).then((dialogId: number) => {
              customDialogId = dialogId
            })
          })
      }
      .width('100%')
    }
    .height('100%')
  }
}
相关推荐
环信即时通讯云2 小时前
环信鸿蒙版 UIKit 快速上手指南
华为·harmonyos
鸿蒙布道师5 小时前
鸿蒙NEXT开发资源工具类(ArkTs)
android·ios·华为·harmonyos·arkts·鸿蒙系统·huawei
别说我什么都不会5 小时前
OpenHarmony 实战开发—— IPC与RPC通信
rpc·harmonyos
二十秒的勇气7 小时前
HarmonyOS:HMPermission权限请求框架
华为·harmonyos
HarmonyOS_SDK7 小时前
页面加载提速37.9%,“凯叔讲故事”做了什么
harmonyos
葱段8 小时前
【Harmony】ArkUI全局设置窗口背景颜色、页面背景颜色
harmonyos·arkts·arkui
鸿蒙布道师10 小时前
鸿蒙NEXT开发设备相关工具类(ArkTs)
android·ios·华为·harmonyos·arkts·鸿蒙系统·huawei
用户00822839813613 小时前
遵循HarmonyOS NEXT UI设计原则,打造卓越用户体验
harmonyos
molong93113 小时前
Android开发鸿蒙环境问题记录
android·华为·harmonyos
琢磨先生David14 小时前
探索 OpenHarmony 开源硬件的学习路径:从入门到实战的全攻略
嵌入式硬件·开源·鸿蒙