@uni/action-sheet
v1.0.8
Published
Readme
actionSheet
Displays the operation menu.
Supported
Install
$ npm install @uni/action-sheet --saveor
$ npm install @uni/apis --saveUsage
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 | ✘ | | |
| options.alertText | string | The alert text | ✘ | | 2.14.0 |
| options.itemColor | string | The text color of the button | ✘ | #000000 | |
| options.cancelButtonText | string | The text of cancel button | ✘ | cancel | |
| options.destructiveBtnIndex | number | get more on ali document | ✘ | | no Dingding |
| options.badges | Array<Object> | get more on ali document | ✘ | | 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 |
