showActionSheet
解释:显示操作菜单
参数:Object
Object参数说明:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
itemList | Array. | 是 | 按钮的文字数组,数组长度最大为6个。 |
itemColor | HexColor | 否 | 按钮的文字颜色,默认颜色为“#3c76ff”。 |
success | Function | 否 | 接口调用成功的回调函数,详见返回参数说明。 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success返回参数说明:
参数名 | 类型 | 说明 |
---|---|---|
tapIndex | Number | 用户点击的按钮,从上到下的顺序,从0开始。 |
示例:在开发者工具中预览效果
- swan.showActionSheet({
itemList: ['同意', '一般', '不同意'],
success: function (res) {
console.log('用户点击了第' + (res.tapIndex + 1) + '按钮');
}
});