Skip to main content
Version: v1.0

hmUI.createDialog(option)

create_dialog

Create a Dialog.

Type

(option: Option) => result

Parameters

Option: object

PropertiesDescriptionRequiredType
titleThe title of the widget.YESstring
showWhether to display Dialog immediately after the creation is completed, default false.NOboolean
click_linsterCallback function, type: 0 click to cancel, type: 1 click to confirm.YES({type: number}) => void
auto_hideWhether the dialog disappears after clicking the "Confirm" or "Cancel" button, default true.NOboolean
caution

Setting auto_hide to false allows the Dialog to be shown and hidden manually through the show API via the Dialog instance method.

If you need to call routing-related APIs like hm.goBack in the popup callback function, it is recommended to set auto_hide to false to make the page jump smoother. Otherwise, when the page is switched, the Dialog popup will be destroyed first, and then the page will be jumped, which will make the page feel switched once more.

dialog instance

dialog.show()

(isShow: boolean) => void
isShowDescription
trueshow
falsehide

Code examples

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)
}
})