文档

动作列表

本文介绍动作列表类WVUIActionSheet相关的JSAPI,供您在通过跨平台DevOps创建H5端应用或者小程序时参考。动作列表类WVUIActionSheet的JSAPI提供显示ActionSheet的相关能力。

WVUIActionSheet.show

显示一个ActionSheet(显示在屏幕下方的动作列表)。

iOS效果

Android 效果

WVUIActionSheet_show_iOS@2x.png WVUIActionSheet_show_Android@2x.png

输入参数

  • [string]title:ActionSheet的标题。

  • [int] index:ActionSheet的索引,用于唯一标识该ActionSheet。

  • [array] buttons:ActionSheet中显示的按钮,每一项都是一个字符串,表示按钮的标题。

    ActionSheet最后总是有一个额外的按钮:取消。

回调参数

无回调参数,如果成功显示ActionSheet,则进入success回调,否则进入failure回调。

监听事件

wv.actionsheet用户响应了ActionSheet。

事件参数:

  • [string]type:用户点击的按钮文本。

  • [int] _index:ActionSheet 的索引。

重要
  • 在iOS平台下,用户点击取消按钮,或者在ActionSheet外点击,都会引发type: '取消' 的事件。

  • 在Android平台下,用户点击取消按钮,会引发不含type属性的事件,在ActionSheet外点击不会引发任何事件。

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

var params = {
        // ActionSheet 的标题
        title: 'Choose a button!',
        // ActionSheet 的索引
        _index: 32768,
        // ActionSheet 中显示的按钮
        buttons: ['按钮 1', '按钮 2', '按钮 3', '按钮 4', '按钮 5']
};
window.WindVane.call('WVUIActionSheet', 'show', params, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});
  • 本页导读 (0)
文档反馈