showMessageBox

Supported from HBuilderX 2.9.12+.

Show a dialog box for selection in the window

Parameter

Name Type Description
options MessageBoxOptions Dialog content

Returns

Type Description
Promise<String> A promise that resolves to the selected resources or undefined.

Dialog properties

Dialog settings, related attributes

Attribute name Type Description
type String Message type,Values are[‘warning’,’info’,’error’,’question’]
title String Dialog title
text String Dialog content
buttons Array<String> Button group in dialog box
defaultButton String Default button index, can be left blank, default 0
escapeButton String The index of the operation button to be executed after the default Esc, can be left blank, the default is 1

Example

  1. let result = hx.window.showMessageBox({
  2. type: 'error',
  3. title: 'Dialog title',
  4. text: 'Dialog content',
  5. buttons: ['Ok', 'Cancel']
  6. });
  7. result.then((button) => {
  8. if (button == 'Ok') {
  9. } else if (button == 'Cancel') {
  10. }
  11. });