HarmonyOS鸿蒙Next中ArkUI简洁的弹窗方式
HarmonyOS鸿蒙Next中ArkUI简洁的弹窗方式
采用下列弹窗方式可直接打开一个弹窗页面,小伙伴们还有其它更为简介的方式吗,欢迎讨论交流,共同进步!!
promptAction.openCustomDialog({
width: 75,
height: 275,
cornerRadius: 0,
offset: { dx: 0, dy: -75 },
maskColor: Color.Transparent,
alignment: DialogAlignment.Bottom,
backgroundColor: Color.Transparent,
backgroundBlurStyle: BlurStyle.NONE,
builder: () => this.todoTargetUpdateView(),
onWillDismiss: async (dismissDialogAction: DismissDialogAction) => {
if (dismissDialogAction.reason == DismissReason.TOUCH_OUTSIDE) {
dismissDialogAction.dismiss()
}
},
}).then((id: number) => {
this.dialogID = id
})
更多关于HarmonyOS鸿蒙Next中ArkUI简洁的弹窗方式的实战教程也可以访问 https://www.itying.com/category-93-b0.html
4 回复
更多关于HarmonyOS鸿蒙Next中ArkUI简洁的弹窗方式的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
在HarmonyOS鸿蒙Next中,ArkUI提供了简洁的弹窗实现方式。通过AlertDialog
组件,可以快速创建弹窗。以下是一个简单示例:
import { AlertDialog } from '@ohos.arkui';
AlertDialog.show({
title: '提示',
message: '这是一个简单的弹窗',
buttons: [
{
text: '确定',
onClick: () => {
console.log('确定按钮被点击');
}
}
]
});
此代码会显示一个带有标题、消息和确定按钮的弹窗。AlertDialog
支持自定义按钮、样式和事件处理,满足不同场景需求。