小程序在使用 wx.showActionSheet 方法时, iOS 与开发者工具上效果一样,而在 Android 机上则是在屏幕中间弹出,只有itemList里的内容,没有取消按钮,所以需要我们添加一下。
var system = wx.getSystemInfoSync() //获取系统信息
var itemList = ['男生', '女生']
if (/android/i.test(system.platform)) {
itemList.push('取消')
}
wx.showActionSheet({
itemList: itemList,
success(res) {
//console.log(res.tapIndex)
}
})