Skip to main content
Version: v2

createModal

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

createModal_image}

Create Modal prompt box.

Type

function createModal(option: Option): Modal

Parameters

Option

PropertyTypeRequiredDefaultValueDescriptionAPI_LEVEL
contentstringY-Content of Modal2.0
showbooleanNfalseWhether to display Modal immediately after the creation is completed2.0
onClick(keyObj: KeyObj) => voidN-Whether to display Modal immediately2.0
autoHidebooleanNtrueWhether to automatically close the Modal dialog after clicking the Confirm or Cancel button2.0

KeyObj

PropertyTypeDescriptionAPI_LEVEL
typenumberModal key name, value reference Modal key name constants2.0
PropertyTypeDescriptionAPI_LEVEL
show(isShow: boolean) => voidShow or hide Modal2.0

Constants

ConstantDescriptionAPI_LEVEL
MODAL_CONFIRMModal Confirm button2.0
MODAL_CANCELModal Cancel button2.0

Example

import { createModal, MODAL_CONFIRM } from '@zos/interaction'

const dialog = createModal({
content: 'hello world',
autoHide: false,
onClick: (keyObj) => {
const { type } = keyObj
if (type === MODAL_CONFIRM) {
console.log('confirm')
} else {
dialog.show(false)
}
},
})

dialog.show(true)