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')
  }
}
相关推荐
盐焗西兰花16 分钟前
鸿蒙学习实战之路-Share Kit系列(12/17)-判断应用是否被系统分享拉起
前端·学习·harmonyos
互联网散修24 分钟前
鸿蒙应用开发UI基础第二十四节:构造Preferences用户首选项数据存储开源工具
开源·harmonyos·鸿蒙应用开发教程
国医中兴2 小时前
Flutter 三方库 ngrouter 鸿蒙适配指南 - 实现高性能扁平化路由导航管理实战
flutter·harmonyos·鸿蒙·openharmony
大雷神3 小时前
HarmonyOS APP<玩转React>开源教程十:组件化开发概述
前端·react.js·开源·harmonyos
国医中兴3 小时前
Flutter 三方库 inject_generator 的鸿蒙化适配指南 - 自动化依赖注入注入生成器、驱动鸿蒙大型工程解耦实战
flutter·harmonyos·鸿蒙·openharmony·inject_generator
Easonmax3 小时前
ReactNative for OpenHarmony项目鸿蒙化三方库:react-native-pager-view — 流畅的页面滑动体验
react native·react.js·harmonyos
讯方洋哥4 小时前
HarmonyOS App开发——鸿蒙ArkTS在手机和PC多终端适配机制应用
harmonyos
以太浮标4 小时前
华为eNSP模拟器综合实验之- 虚拟路由冗余协议VRRP(Virtual Router Redundancy Protocol)解析
网络·网络协议·华为·智能路由器·信息与通信
国医中兴4 小时前
Flutter 三方库 themed_color_palette 的鸿蒙化适配指南 - 定义语义化调色板、在鸿蒙端实现像素级的主题切换实战
flutter·harmonyos·鸿蒙·openharmony·themed_color_palette
国医中兴5 小时前
Flutter 三方库 aws_sqs_api 鸿蒙适配指南 - 实现分布式消息异步解耦、在 OpenHarmony 上打造高可用云端队列控制中枢实战
flutter·harmonyos·aws