Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@uni/action-sheet

raxjs2.8kBSD-3-Clause1.0.8TypeScript support: included

null

readme

actionSheet

npm

Displays the operation menu.

Supported

browser weex miniApp wechatMiniprogram bytedanceMicroApp baiduSmartProgram kuaiShouMiniProgram

Install

$ npm install @uni/action-sheet --save

or

$ npm install @uni/apis --save

Usage

import showActionSheet from '@uni/action-sheet';

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

// promise
showActionSheet({
  itemList: ['A', 'B', 'C']
}).then(res => {
    console.log(res.tapIndex)
});

You can also import from the big package:

import { actionSheet } from '@uni/apis';
actionSheet({
  itemList: ['A', 'B', 'C']
}).then(res => {
  console.log(res.tapIndex)
});

Methods

showActionSheet(options)

Arguments

Property Type Description required Default
options object | ✔️ -
options.itemList Array<string> The text array of the button, with a length limited to 6 ✔️ -
options.success Function The callback function for a successful API call -
options.fail Function The callback function for a failed API call -
options.complete Function The callback function used when the API call completed (always executed whether the call succeeds or fails) -

Special Arguments

Property Type Description required Default Supported
options.title string The title of actionsheet | miniApp
options.alertText string The alert text | wechatMiniprogram 2.14.0
options.itemColor string The text color of the button #000000 wechatMiniprogram baiduSmartProgram kuaiShouMiniProgram
options.cancelButtonText string The text of cancel button cancel miniApp
options.destructiveBtnIndex number get more on ali document | miniApp no Dingding
options.badges Array<Object> get more on ali document | miniApp no Dingding

Return

Property Type Description
tapIndex number The sequence number of the button tapped by the user, from top to bottom and starting from 0, The value is -1 when the mask or cancel button is clicked by the user
wechat miniprogram