代码拉取完成,页面将自动刷新
本示例在一个非@Entry的类中创建一个CustomDialogController弹窗,以此来实现不依赖entry的弹窗。
本示例仅支持标准系统上运行,支持设备:华为手机。
HarmonyOS系统:HarmonyOS NEXT Release及以上。
DevEco Studio版本:DevEco Studio NEXT Release及以上。
HarmonyOS SDK版本:HarmonyOS NEXT Release SDK及以上。
点击请求网络按钮,触发不依赖entry的弹窗。
export function testPromptDialog() {
const that = GlobalContext.getContext().getObject('UIContext') as UIContext;
if (that) {
promptAction.openCustomDialog({
builder: customDialogBuilder.bind(that, '网络请求失败!')
}).then((dialogId: number) => {
customDialogId = dialogId;
})
}
}
export function customDialogBuilder(content: String) {
Column() {
Text(`Tip: ${content} `).fontSize(20).height('30%')
Text('失败原因:!!!!').fontSize(16).height('30%')
Row() {
Button('确认').onClick(() => {
promptAction.closeCustomDialog(customDialogId)
})
Blank().width(50)
Button('取消').onClick(() => {
promptAction.closeCustomDialog(customDialogId)
})
}
.margin({top: 30})
}.height(200).padding(5)
}
├──entry/src/main/ets // 代码区
│ ├──entryability
│ │ └──EntryAbility.ets // 程序入口类
│ └──pages
│ ├──Index.ets // 主页面
│ ├──MyShowText.ets // 弹窗页面
│ ├──HttpUtils.ets
│ └──GlobalContext.ets
└──entry/src/main/resources // 资应用资源目录
亲爱的Harmony Next开发者,您好!
为了协助您高效开发,提高鸿蒙场景化示例的质量,希望您在浏览或使用后抽空填写一份简单的问卷,我们将会收集您的宝贵意见进行优化
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。