Skip to main content
版本:v3+

createModal

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

createModal_image

创建 Modal 确认提示框。

类型​

function createModal(option: Option): Modal

参数​

Option​

属性类型必填默认值说明API_LEVEL
contentstring是-Modal 对话框的标题2.0
titlestring否-Modal 对话框的标题,content 的别名3.6
showboolean否true完成创建后是否立即显示 Modal 对话框2.0
onClick(keyObj: KeyObj) => void否-点击确认或者取消的回调函数2.0
autoHideboolean否true点击确认或者取消按钮后,是否自动关闭 Modal 对话框2.0
subtitlestring否-子标题3.6
srcstring否-icon 图标路径3.6
textstring否-文本内容3.6
textColornumber否0xFFFFFF文本颜色3.6
textAlphanumber否255文本透明度,透明度[0-255],0 为全透明3.6
okButtonstring否-确认按钮的 icon 图标路径3.6
cancelButtonstring否-取消按钮的 icon 图标路径3.6
capsuleButtonArray<string>否-胶囊按钮配置,为字符串数组,点击返回的 KeyObj 中的 type 从 10 开始3.6

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)