ArkUI---使用弹窗---@ohos.promptAction (弹窗)

promptAction.showToast(文本提示框)

showToast(options: ShowToastOptions): void

创建并显示文本提示框,想看官方文档请点我
ShowToastOptions相关参数请点我

完整代码:

typescript 复制代码
import { promptAction } from '@kit.ArkUI'

@Entry
@Component
struct Demo1 {
  build() {
    Column(){
      Button('点击我,弹出提示文本框!').onClick(_=>{
        promptAction.showToast({
          message: 'Hello World!',
          duration:2000
        })
      })

    }.height('100%').width('100%').justifyContent(FlexAlign.Center)
  }
}

promptAction.showDialog(对话框)

showDialog(options: ShowDialogOptions): Promise

创建并显示对话框,对话框响应后异步返回结果。想看官方文档请点我
ShowDialogOptions相关参数请点我


完整代码:

typescript 复制代码
import { promptAction } from '@kit.ArkUI'

@Entry
@Component
struct Demo1 {
  build() {
   Button('点击出现对话框!').onClick(async _=>{
     await promptAction.showDialog({
       title:'Title标题',
       message:'Message Info',
       buttons:[
         {
           text:'button1',
           color:'#000000'
         },
         {
           text:'button2',
           color:'#000000'
         }
       ],
     })
   }).width(200).height('80')
  }
}
相关推荐
贾伟康1 小时前
【HarmonyOS 7新能力|008】互动卡片入门实战:从能力边界到最小可运行链路
harmonyos·arkts·arkui·harmonyos 7·互动卡片
●VON2 小时前
Flutter 鸿蒙插件适配实战:用 clipboard_watcher 0.3.0 监听剪贴板变化
flutter·华为·harmonyos
昇腾知识体系3 小时前
CANN 安装升级避坑:version.cfg 查版本、银河麒麟找不到驱动、nnrt --version 无输出排查
人工智能·华为·知识图谱
贾伟康4 小时前
【HarmonyOS 7新能力|005】沉浸光感入门实战:从能力边界到最小可运行链路
harmonyos·arkts·arkui·harmonyos 7·交互动效
心态还需努力呀10 小时前
把 Flameshot 编译进鸿蒙 PC:一次 Qt C++ 截图工具的源码级移植实战
c++·qt·harmonyos
心态还需努力呀10 小时前
把 Zettlr 搬上鸿蒙 PC:一次 Electron 应用移植实战
华为·electron·harmonyos
OH_TPC10 小时前
HarmonyOS APP开发---“心动卡“社交匹配App,需要用到这个库
华为·harmonyos·鸿蒙
●VON11 小时前
Flutter 鸿蒙插件适配实战:用 is_lock_screen 2.0.0 判断真实锁屏状态
flutter·华为·harmonyos
Sunny_G11 小时前
鸿蒙 Markdown 编辑器表格所见即所得:七个版本的渲染重构(CodeMirror Decoration 实战)
ai编程·harmonyos