HomeDocs
Skip to main content

dlt.showModal

Introduction

Displays a modal dialog box.

Parameters

PropertyRequiredTypeDefaultDescriptionMinimum Version
titleNostringThe title of the modal dialog box.
contentNostringThe content of the modal dialog box.
showCancelNobooleanfalseWhether to show the cancel button.
cancelTextNostringCancelThe text of the cancel button, up to 12 characters.
cancelColorNostring#92969EThe text color of the cancel button in hexadecimal format.
confirmTextNostringConfirmThe text of the confirm button, up to 12 English characters.
confirmColorNostring#0081FFThe text color of the confirm button in hexadecimal format.
editableNobooleanfalseWhether to show an input box.3.0.0
placeholderTextNostringThe placeholder text when displaying an input box.3.0.0
successNofunctionCallback function for a successful API call.
failNofunctionCallback function for a failed API call.
completeNofunctionCallback function that will be executed when the API call is complete (both successful and failed calls).

success Callback Function

Parameters

Object res

PropertyTypeDescription
successstringtrue - successful
confirmbooleanWhen confirm is true, it means the user clicked the confirm button.
cancelbooleanWhen cancel is true, it means the user clicked the cancel button.
contentstringWhen editable is true, it represents the text entered by the user.

fail Callback Function

Parameters

Object res

PropertyTypeDescription
successstringfalse - failed

Example Code

// pages/index/index.js
Page({
showModal() {
dlt.showModal({
title: "提示",
content: "这是一个模态弹窗",
success(res) {
if (res.confirm) {
console.log("用户点击确定");
} else if (res.cancel) {
console.log("用户点击取消");
}
},
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.