mc.showModal(Object object)
显示模态对话框
Object object 参数
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
title | String | 否 | 提示的标题 | |
content | String | 否 | 提示的内容 | |
showCancel | Boolean | true | 否 | 是否显示取消按钮 |
cancelText | String | '取消' | 否 | 取消按钮的文字,最多 4 个字符 |
cancelColor | String | #000000 | 否 | 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串 |
confirmText | String | '确定' | 否 | 确认按钮的文字,最多 4 个字符 |
confirmColor | String | #576b95 | 否 | 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串 |
editable | Boolean | false | 否 | 是否显示输入框 |
placeholderText | String | 否 | 显示输入框时的提示文本 | |
success | Function | 否 | 接口调用成功的回调函数 | |
fail | Function | 否 | 接口调用失败的回调函数 | |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
Object.success(Object res) 回调参数
属性 | 类型 | 说明 |
---|---|---|
content | String | 用户输入的文本 editable 为 true 且 confirm 为true时有效 |
confirm | Boolean | 为 true 时,表示用户点击了确定按钮 |
cancel | Boolean | 为 true 时,表示用户点击了取消按钮 |
示例代码:
mc.showModal({
title: '提示',
content: '这是一个模态弹窗',
success(res) {
if (res.confirm) {
mc.showToast({
'title': '用户点击确定'
});
} else if (res.cancel) {
mc.showToast({
'title': '用户点击取消'
});
}
}
})
mc.showModal({
title: '提示',
content: '这是一个带输入框的弹窗',
editable: true,
success(res) {
if (res.confirm) {
console.log('用户输入了' + res.content);
} else if (res.cancel) {
console.log('用户点击取消');
}
}
})