HomeDocs
Skip to main content

dlt.showActionSheet

Introduction

Displays an action sheet menu.

Usage Restrictions

Supported in the base library version 3.0.0 or higher.

Parameters

Object object

PropertyTypeDefaultRequiredDescription
alertTextstringNoAlert text
itemListstring[]YesMenu configuration items, at least 1 and up to 6
itemColorstring#000000NoThe text color of the buttons
typestringtextNoType
- text: the action is centered text
- icon: the action is text with an icon aligned to the left
titlestringNoTitle (if not provided, the title will not be displayed)
showCancelbooleantrueNoWhether to show the cancel button
cancelTextstringCancelNoThe text of the cancel button
cancelColorstring#191F2BNoThe text color of the cancel button, supports AHEX format
actionsActions[]YesMenu configuration items, at least 1 and up to 6 (actions or itemList is required)
successfunctionNoCallback function for a successful API call
failfunctionNoCallback function for a failed API call
completefunctionNoCallback function that will be executed when the API call is complete (both successful and failed calls)

Action Explanation

PropertyTypeDefaultRequiredDescription
textstringYesButton text, can be used for multi-language scenarios
colorstring#FF191F2BNoButton default color
disabledColorstring#4D191F2BNoButton disabled color
enablebooleantrueNoButton state, true for enabled, false for disabled (if disabled, disabledColor will be used, otherwise color)
iconstringNoMenu icon, relative address or CDN address Note: Only valid when type is icon
maskColorstring#0F191F2BNoButton press mask, supports AHEX format

success Callback Function

Parameters

Object res

PropertyTypeDescription
successstringtrue - successful
tapIndexnumberThe index of the button that the user clicked, starting from 0 in top-to-bottom order
contentstringThe content of the clicked action item

fail Callback Function

Parameters

Object res

PropertyTypeDescription
errMsgstring1. Parameter error: AS10001
2. ${type} is not supported: AS10002
3. Invalid ${size}, must be between ${MIN_SIZE} and ${MAX_SIZE} : AS10003
successstringfalse - failed

Example Code

// pages/index/index.js
Page({
showActionSheet() {
dlt.showActionSheet({
itemList: ["A", "B", "C"],
success(res) {
console.log(res.tapIndex);
},
fail(res) {
console.log(res.errMsg);
},
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.