Action list

更新时间:
复制 MD 格式

This topic describes the JavaScript APIs (JSAPIs) for the WVUIActionSheet class. You can use these JSAPIs to display an ActionSheet when you create H5 applications or miniapps with cross-platform DevOps.

WVUIActionSheet.show

Displays an ActionSheet, which is a list of actions that appears at the bottom of the screen.

iOS effect

Android effect

WVUIActionSheet_show_iOS@2x.png

WVUIActionSheet_show_Android@2x.png

Input parameters

  • [string] title: The title of the ActionSheet.

  • [int] index: The unique index that identifies the ActionSheet.

  • [array] buttons: The buttons to display in the ActionSheet. Each item is a string that represents the title of a button.

    The ActionSheet always has an extra button at the end: Cancel.

Callback parameters

This action has no callback parameters. The success callback is triggered if the ActionSheet is displayed successfully. Otherwise, the failure callback is triggered.

Listener event

wv.actionsheet: Triggered when a user selects an option from the ActionSheet.

Event parameters:

  • [string] type: The title of the button that the user clicks.

  • [int] _index: The index of the ActionSheet.

Important
  • On iOS, if a user clicks the Cancel button or taps outside the ActionSheet, an event with type: 'Cancel' is triggered.

  • On Android, if a user clicks the Cancel button, an event is triggered that does not contain the type property. Tapping outside the ActionSheet does not trigger an event.

document.addEventListener('wv.actionsheet', function(e) {
        alert(JSON.stringify(e.param));
}, false);

var params = {
        // The title of the ActionSheet
        title: 'Choose a button!',
        // The index of the ActionSheet
        _index: 32768,
        // The buttons displayed in the ActionSheet
        buttons: ['Button 1', 'Button 2', 'Button 3', 'Button 4', 'Button 5']
};
window.WindVane.call('WVUIActionSheet', 'show', params, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});