WeChat小程序交流(QQ群:769977169)
效果图
代码示例
xxx.wxml
<button bindtap='imageClick'>选择图片</button>
xxx.wxjs
Page({
imageClick: function() {
wx.showActionSheet({
itemList: ['相册', '拍照'],
success: function (res) {
console.log(res.tapIndex)
if (0 == res.tapIndex) {
wx.showToast({
title: '你选择了相册',
})
} else if (1 == res.tapIndex) {
wx.showToast({
title: '你选择了拍照',
})
}
},
fail: function (res) {
console.log(res.errMsg)
}
})
}
}