- 导入模块
import promptAction from '@ohos.promptAction'
一、文体提示 弹窗(类似:Android Toast): promptAction.showToast()
import promptAction from '@ohos.promptAction'
@Entry
@Component
struct RadioExample {
build() {
Row() {
Button("1122")
.onClick(() => {
promptAction.showToast({message: "message", duration:3000, bottom:400})
})
}
}
}
二、对话框 弹窗: promptAction.showDialog()
// xxx.ets
// xxx.ets
import promptAction from '@ohos.promptAction'
const TAG = "huxiubo"
@Entry
@Component
struct RadioExample {
build() {
Row() {
Button("1122")
.onClick(() => {
promptAction.showDialog(
{
title: 'title',
message:'message',
buttons: [
{
text: 'button1',
color: '#000000',
},
{
text: 'button2',
color: '#000000',
}
]
}
)
.then((data) => {
console.info(TAG, `Successed:${JSON.stringify(data)}`);
})
.catch((err: Error) => {
console.error(TAG, `error: ${JSON.stringify(err)}`)
})
})
}
}
}
三、菜单 弹窗 : promptAction.showActionMenu
和 promptAction.showDialog 少了个 message:'message'
// xxx.ets
import promptAction from '@ohos.promptAction'
const TAG = "huxiubo"
@Entry
@Component
struct RadioExample {
build() {
Row() {
Button("1122")
.onClick(() => {
promptAction.showActionMenu(
{
title: 'title',
buttons: [
{
text: 'button1',
color: '#000000',
},
{
text: 'button2',
color: '#000000',
}
]
}
)
.then((data) => {
console.info(TAG, `Successed:${JSON.stringify(data)}`);
})
.catch((err: Error) => {
console.error(TAG, `error: ${JSON.stringify(err)}`)
})
})
}
}
}
网友评论