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')
  }
}
相关推荐
Industio_触觉智能2 小时前
用鸿蒙开发鸿蒙!DevEco三件套已支持鸿蒙PC|触觉智能鸿蒙南向嵌入式厂家
华为·harmonyos·鸿蒙·鸿蒙系统·开发板·openharmony·开源鸿蒙
fleaxin8 小时前
Atlas 300V:(3)模型精度数据对比
yolo·华为·atlas
威哥爱编程8 小时前
HarmonyOS 7 Agent 开发实战 08:结构化输出解析
agent·harmonyos
威哥爱编程8 小时前
HarmonyOS 7 Agent 开发实战 09:Agent 测试评测集
agent·harmonyos
Eyfcom13 小时前
〖深度〗鸿蒙 ArkTS 移动应用开发经验:从 TypeScript 心智模型到声明式运行时的六层认知重构
typescript·移动开发·harmonyos·arkts
程序猿追13 小时前
把一份背包数据装进 NBT:KNBT 在鸿蒙上的标签与压缩实验
华为·harmonyos
行走的小派16 小时前
Harmony文件管理子系统实践:纯文本编辑器的大文件加载与编码处理
harmonyos·香橙派·应用开发
hqzing17 小时前
在鸿蒙 PC 上使用 apt 安装 Debian 软件包(非虚拟机、非容器)
华为·debian·harmonyos
Marco_Marco13517 小时前
定位SDK接入实战:Android/iOS/鸿蒙三端怎么选、怎么接
android·ios·harmonyos