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')
  }
}
相关推荐
OH_TPC2 小时前
HarmonyOS APP开发---"菜谱汇"美食菜谱App,需要用到这个库
harmonyos
老陈说编程2 小时前
2. 鸿蒙(HarmonyOS)超级终端与生态
华为·harmonyos
2501_919749033 小时前
华为鸿蒙免费时钟工具—小羊时钟
华为·harmonyos
aqi0014 小时前
鸿蒙版本的电子书阅读APP开放源码啦
android·华为·ai编程·harmonyos·鸿蒙
xq952718 小时前
HDC Assistant 插件横空出世
harmonyos
垆边人似月.20 小时前
华为机试题 :两数之和
c++·算法·华为
垆边人似月.20 小时前
华为机试题 :有效的括号
c++·算法·华为
高德开放平台1 天前
高德开放平台×华为:一句话,开启腕上打车
华为
垆边人似月.1 天前
华为机试题 :字符串压缩
算法·华为
OH_TPC1 天前
【鸿蒙优选三方库】@ohos/aki:一行代码让 ArkTS 调 C++
harmonyos