Skip to main content
Version: 3.x

Taro.showActionSheet(option)

Displays the operation menu.

Note

  • For Android 6.7.2 and below, when you tap Cancel or Mask, the callback will fail with the errMsg of "fail cancel".
  • For Android 6.7.2 & above and iOS, tapping Mask will not close the modal dialog box, so avoid using the "Cancel" branch to implement the business logic.

Reference

Type

(option: Option) => Promise<SuccessCallbackResult>

Parameters

Option

PropertyTypeRequiredDescription
itemListstring[]YesThe text array of the button, with a length limited to 6
itemColorstringNoThe text color of the button
success(result: CallbackResult) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: CallbackResult) => voidNoThe callback function for a failed API call
complete(res: CallbackResult) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)

SuccessCallbackResult

PropertyTypeDescription
tapIndexnumberThe sequence number of the button tapped by the user, from top to bottom and starting from 0
errMsgstringcall result

Sample Code

Taro.showActionSheet({
itemList: ['A', 'B', 'C'],
success: function (res) {
console.log(res.tapIndex)
},
fail: function (res) {
console.log(res.errMsg)
}
})

API Support

APIWeChat Mini-ProgramH5React Native
Taro.showActionSheet✔️✔️✔️