鸿蒙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%')
  }
}
相关推荐
张帅涛_6663 小时前
HarmonyOS开发之全局状态管理
华为·harmonyos
让开,我要吃人了3 小时前
HarmonyOS开发实战( Beta5.0)蓝牙实现服务端和客户端通讯详解
开发语言·前端·华为·移动开发·harmonyos·鸿蒙·鸿蒙系统
让开,我要吃人了4 小时前
HarmonyOS应用开发( Beta5.0)HOS-用户认证服务:面部识别
服务器·前端·华为·移动开发·嵌入式·harmonyos·鸿蒙
让开,我要吃人了7 小时前
HarmonyOS开发实战( Beta5.0)橡皮擦案例实践详解
开发语言·前端·华为·移动开发·harmonyos·鸿蒙·鸿蒙系统
ImomoTo7 小时前
HarmonyOS学习(十一)——安全管理
学习·安全·harmonyos·arkts·arkui
爱桥代码的程序媛16 小时前
HarmonyOS开发5.0【应用程序包】
分布式·harmonyos·鸿蒙·鸿蒙系统·openharmony·鸿蒙开发·程序包
爱桥代码的程序媛16 小时前
HarmonyOS开发5.0【rcp网络请求】
网络·移动开发·harmonyos·鸿蒙·鸿蒙系统·openharmony·rcp
让开,我要吃人了16 小时前
HarmonyOS应用开发( Beta5.0)一杯冰美式的时间“拿捏Grid组件”
服务器·前端·华为·移动开发·harmonyos·鸿蒙·openharmony
Android技术栈17 小时前
鸿蒙开发(API 12 Beta6版)【P2P模式】 网络WLAN服务开发
网络·harmonyos·鸿蒙·鸿蒙系统·p2p·openharmony·wlan
Android技术栈18 小时前
鸿蒙(API 12 Beta6版)图形加速【OpenGL ES平台内插模式】超帧功能开发
elasticsearch·harmonyos·鸿蒙·鸿蒙系统·openharmony·图形·超帧