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')
  }
}
相关推荐
Georgewu14 分钟前
【HarmonyOS AI 系列文章】 图像超分:用端侧 AI 实现小图传输,高清图呈现
harmonyos
不羁的木木37 分钟前
HarmonyOS APP实战-画图APP - 第5篇:画笔属性调节
华为·harmonyos
想你依然心痛2 小时前
HarmonyOS 6(API 23)实战:基于HMAF的「智链中枢」——PC端AI智能体多Agent协同编排与任务调度平台
人工智能·华为·harmonyos·智能体
春卷同学2 小时前
HarmonyOS掌上记账APP开发实践第12篇:@Type 装饰器 — 解决嵌套对象响应式的终极方案
harmonyos
不羁的木木2 小时前
HarmonyOS APP实战-基于Image Kit的图像处理APP - 第9篇:批量处理与编辑历史
图像处理·ubuntu·harmonyos
春卷同学3 小时前
HarmonyOS掌上记账APP开发实践第15篇:ArkTS 类型系统深度解析 — 从接口到联合类型的灵活运用
ubuntu·华为·harmonyos
春卷同学3 小时前
HarmonyOS掌上记账APP开发实践第11篇:@Local 组件级状态 — 比 @State 更精确的局部状态管理
harmonyos
ldsweet4 小时前
《HarmonyOS技术精讲-Basic Services Kit》公共事件进阶:粘性事件与有序广播
华为·harmonyos
2301_768103494 小时前
HarmonyOS趣味相机实战第11篇:从单摄切换升级前后双摄同开、能力探测与降级设计
harmonyos·arkts·camerakit·双摄同开·能力降级
AD02274 小时前
27-RDB写一半数据不一致-用事务边界和补偿日志兜住
harmonyos·arkts·鸿蒙开发