Skip to main content
版本:v2

createModal

API_LEVEL 2.0 开始支持,API 兼容性请参考 API_LEVEL。

createModal_image}

创建 Modal 确认提示框。

类型​

function createModal(option: Option): Modal

参数​

Option​

属性类型必填默认值说明API_LEVEL
contentstring是-Modal 对话框的内容2.0
showboolean否false完成创建后是否立即显示 Modal 对话框2.0
onClick(keyObj: KeyObj) => void否-点击确认或者取消的回调函数2.0
autoHideboolean否true点击确认或者取消按钮后,是否自动关闭 Modal 对话框2.0

KeyObj​

属性类型说明API_LEVEL
typenumberModal 按键名,值参考 Modal 按键名常量2.0
属性类型说明API_LEVEL
show(isShow: boolean) => void显示或隐藏 Modal 对话框2.0

常量​

常量说明API_LEVEL
MODAL_CONFIRMModal 确认按键2.0
MODAL_CANCELModal 取消按键2.0

代码示例​

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)