鸿蒙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%')
  }
}
相关推荐
2501_919749038 分钟前
华为鸿蒙免费日记本—小羊日记
华为·harmonyos·鸿蒙
m0_7381858227 分钟前
Flutter 鸿蒙化实战:rive 适配 OpenHarmony,Rive 动画
flutter·华为·harmonyos·鸿蒙
zd20057244 分钟前
我给x86版本开源鸿蒙系统装上了 Homebrew,还塞了整个 Node 和 opencode 进去
华为·开源·harmonyos
song5011 小时前
React Native for OpenHarmony 实战:三方库 react-native-popup-menu 的鸿蒙化适配指南
css·深度学习·react native·react.js·transformer·harmonyos
打工仔折腾 AI1 小时前
鸿蒙版ToDesk远控实测:蓝牙键鼠、双模式鼠标与跨端剪贴板怎么用
后端·python·华为·性能优化·计算机外设·harmonyos·ai agent 实战
特立独行的猫a1 小时前
仓颉语言实现强大的Modbus调试工具Modbus Poll:cj-tauri项目介绍与实战
harmonyos·tauri·modbus·仓颉·modbus poll
m0_7381858213 小时前
Flutter 鸿蒙化实战:screen_protector 适配 OpenHarmony,防截屏/防泄露
flutter·华为·harmonyos·鸿蒙
CV工程师丁Sir14 小时前
# ArkWeb 手记 03|本地资源加载与 $rawfile 路径踩坑
harmonyos
OH_TPC1 天前
HarmonyOS APP开发---"菜谱汇"美食菜谱App,需要用到这个库
harmonyos