Skip to content

mpx.showModal(Object object)

显示模态对话框

支持情况: 微信、支付宝、web、RN

参考文档

参数

Object object

属性类型默认值必填说明最低版本支付宝RNweb
titlestring提示的标题
contentstring提示的内容
showCancelbooleantrue是否显示取消按钮
cancelTextstring取消取消按钮的文字,最多 4 个字符
cancelColorstring#000000取消按钮的文字颜色,必须是 16 进制格式的颜色字符串
confirmTextstring确定确认按钮的文字,最多 4 个字符
confirmColorstring#576B95确认按钮的文字颜色,必须是 16 进制格式的颜色字符串
editablebooleanfalse是否显示输入框2.17.1
placeholderTextstring显示输入框时的提示文本2.17.1
successfunction接口调用成功的回调函数
failfunction接口调用失败的回调函数
completefunction接口调用结束的回调函数(调用成功、失败都会执行)

object.success 回调函数

参数

Object res

属性类型说明最低版本
contentstringeditable 为 true 时,用户输入的文本
confirmboolean为 true 时,表示用户点击了确定按钮
cancelboolean为 true 时,表示用户点击了取消(用于 Android 区分关闭方式)1.1.0

示例代码

js
mpx.showModal({
  title: '提示',
  content: '这是一个模态弹窗',
  success (res) {
    if (res.confirm) {
      console.log('用户点击确定')
    } else if (res.cancel) {
      console.log('用户点击取消')
    }
  }
})