# uni.showModal(options)

显示模态弹窗,可以只有一个确定按钮,也可以同时有确定和取消按钮。类似于一个API整合了 html 中:alert、confirm。

# # 参数

名称 类型 必填 默认值 描述
options ShowModalOptions 是 - uni.showModal 参数定义

# # ShowModalOptions 属性值

名称 类型 必备 默认值 描述
title string 否 - 提示的标题
content string 否 - 提示的内容
showCancel boolean 否 true
是否显示取消按钮,默认为 true
cancelText string 否 - 取消按钮的文字,默认为"取消"
cancelColor string 否 - 取消按钮的文字颜色,默认为"#000000"
confirmText string 否 - 确定按钮的文字,默认为"确定"
confirmColor string 否 - 确定按钮的文字颜色
editable boolean 否 false
是否显示输入框
placeholderText string 否 - 显示输入框时的提示文本
success (res: ShowModalSuccess) => void 否 - 接口调用成功的回调函数
fail (res: UniError) => void 否 - 接口调用失败的回调函数
complete (res: any) => void 否 - 接口调用结束的回调函数(调用成功、失败都会执行)
# # ShowModalSuccess 属性值
名称 类型 必备 默认值 描述
confirm boolean 是 - 为 true 时,表示用户点击了确定按钮
cancel boolean 是 - 为 true 时,表示用户点击了取消(用于 Android 系统区分点击蒙层关闭还是点击取消按钮关闭)
content string 否 - editable 为 true 时,用户输入的文本

# # showModal 兼容性

安卓系统版本 安卓 uni-app 安卓 uni-app-x iOS 系统版本 iOS uni-app iOS uni-app-x
4.4.4 √ 3.9.0 9.0 √ 3.9.0

# # 参见

showModal

# # 通用类型

# # GeneralCallbackResult

名称 类型 必备 默认值 描述
errMsg string 是 - 错误信息