title: Taro.showActionSheet(option)

sidebar_label: showActionSheet

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

  1. (option: Option) => Promise<SuccessCallbackResult>

Parameters

Option

Property Type Required Description
itemList string[] Yes The text array of the button, with a length limited to 6
itemColor string No The text color of the button
success (result: CallbackResult) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
fail (res: CallbackResult) => void No The callback function for a failed API call
complete (res: CallbackResult) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)

SuccessCallbackResult

Property Type Description
tapIndex number The sequence number of the button tapped by the user, from top to bottom and starting from 0
errMsg string call result

Sample Code

  1. Taro.showActionSheet({
  2. itemList: ['A', 'B', 'C'],
  3. success: function (res) {
  4. console.log(res.tapIndex)
  5. },
  6. fail: function (res) {
  7. console.log(res.errMsg)
  8. }
  9. })

API Support

API WeChat Mini-Program H5 React Native
Taro.showActionSheet ✔️ ✔️ ✔️