鸿蒙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%')
  }
}
相关推荐
猛扇赵四那边好嘴.3 小时前
Flutter 框架跨平台鸿蒙开发 - 非遗文化查询:传承中华文化瑰宝
flutter·华为·harmonyos
小学生波波3 小时前
HarmonyOS6 - 鸿蒙AI人脸比对实战案例
ai·arkts·鸿蒙·harmonyos6·比对人脸
小风呼呼吹儿6 小时前
Flutter 框架跨平台鸿蒙开发 - 家庭用药清单:智能管理家庭药品
flutter·华为·harmonyos
纯爱掌门人6 小时前
鸿蒙端云一体化开发(二):云数据库
数据库·华为·harmonyos·端云一体化
小雨青年6 小时前
【鸿蒙原生开发会议随记 Pro】 数据存储架构 RelationalStore 在复杂资产管理中的应用
华为·架构·harmonyos
djarmy8 小时前
跨平台Flutter 开源鸿蒙开发指南(三):使用thirdParty的dio库实现网络请求 示例
flutter·华为·harmonyos
Miguo94well8 小时前
Flutter框架跨平台鸿蒙开发——护眼提醒APP的开发流程
flutter·华为·harmonyos·鸿蒙
zilikew10 小时前
Flutter框架跨平台鸿蒙开发——拼图游戏的开发流程
flutter·华为·harmonyos·鸿蒙
Easonmax11 小时前
基础入门 React Native 鸿蒙跨平台开发:帮助中心页面完整实现(常见问题+搜索+分类)
react native·react.js·harmonyos
猛扇赵四那边好嘴.11 小时前
Flutter 框架跨平台鸿蒙开发 - 手工皮具制作记录:打造专业级皮具制作管理工具
flutter·华为·harmonyos