HarmonyOS 鸿蒙Next 自定义弹窗CustomDialog,支持滑动关闭吗?
HarmonyOS 鸿蒙Next 自定义弹窗CustomDialog,支持滑动关闭吗?
关于HarmonyOS 鸿蒙Next 自定义弹窗CustomDialog,支持滑动关闭吗?的问题,您也可以访问:https://www.itying.com/category-93-b0.html 联系官网客服。
[@Entry](/user/Entry)
struct bindSheetExample {
@State isShow: Boolean = false;
myBuilder() {
Column() {
Text(“CONTEXT”)
}
}
build() {
Column() {
Button(“弹出”)
.onClick(() => {
this.isShow = true
})
.fontSize(20)
.margin(10)
.bindSheet($$this.isShow, this.myBuilder(), {
height: SheetSize.MEDIUM,
blurStyle: BlurStyle.Thick,
title: { title: “title”, subtitle: “subtitle” },
preferType: SheetType.CENTER,
showClose: false,
onWillDismiss: ((DismissSheetAction: DismissSheetAction) => {
if (DismissSheetAction.reason == DismissReason.SLIDE_DOWN) {
DismissSheetAction.dismiss() //注册dismiss行为
}
}),
onWillSpringBackWhenDismiss: ((SpringBackAction: SpringBackAction) => {
//没有注册springBack, 下拉半模态页面无回弹行为
// SpringBackAction.springBack()
}),
})
}
}
}
<button style="position: absolute; padding: 4px 8px 0px; cursor: pointer; top: 8px; right: 8px; font-size: 14px;">复制</button>
更多关于HarmonyOS 鸿蒙Next 自定义弹窗CustomDialog,支持滑动关闭吗?的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
感谢
可以看看onBackPress回调函数,在里面调用关闭弹窗
onBackPress?(): void | boolean
当用户点击返回按钮时触发,仅[@Entry](/user/Entry)装饰的自定义组件生效。返回true表示页面自己处理返回逻辑,不进行页面路由;返回false表示使用默认的路由返回逻辑,不设置返回值按照false处理。