微信小程序
wx.showModal
# wx.showModal(Object object)
以 Promise 风格 调用:支持
小程序插件:支持,需要小程序基础库版本不低于 1.9.6
微信 Windows 版:支持
微信 Mac 版:支持
# 功能描述
显示模态对话框
# 参数
# Object object
# object.success 回调函数
# 参数
# Object res
# 示例代码
wx.showModal({
title: '提示',
content: '这是一个模态弹窗',
success (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
# 注意
- Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
- Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
- 自基础库 2.17.1 版本起,支持传入 editable 参数,显示带输入框的弹窗