Skip to main content
版本:v1.0

hmUI.createDialog(option)

create_dialog

创建 Dialog 对话框。

类型

(option: Option) => dialog

参数

Option: object

属性说明是否必须类型
title标题string
show完成创建后是否立即显示 Dialog 对话框boolean
click_linster回调函数,type: 0 点击取消、type: 1 点击确认({type: number}) => void
auto_hide弹窗是否在点击「确认」或者「取消」按钮之后消失,默认 trueboolean
警告

auto_hidefalse 即可通过 Dialog 实例方法,通过 show API 手动控制 Dialog 显示隐藏。

如果需要在弹窗回调函数中调用路由相关 API 如 hm.goBack,建议将 auto_hide 设置为 false,这样可以让页面跳转更加平滑。否则页面切换时,先销毁 Dialog 弹窗,再进行页面跳转,视觉上会感觉多切换一次。

dialog 实例

dialog.show()

(isShow: boolean) => void
isShow说明
true显示
false隐藏

代码示例

Page({
build() {
const dialog = hmUI.createDialog({
title: 'HELLO ZEPP OS',
auto_hide: false,
click_linster: ({ type }) => {
dialog.show(false)
console.log('type', type)
console.log('click dialog')
}
})

dialog.show(true)
}
})