在wx.showActionSheet内使用wx.chooseImage时, 异常
发布于 5 年前 作者 xiulan76 1543 次浏览 来自 官方Issues

我想实现的需求: 点击按钮弹出actionsheet, 点击其中一项, 执行wx.chooseImage, 在相册中选择照片;

实际表现: 点击按钮弹出actionsheet, 点击其中一项, wx.chooseImage没有执行, 而是又__重新弹出了一遍actionsheet__, 再次点击其中一项, wx.chooseImage可正常执行;

代码:

chooseImageActionNow: function (e){

var that = this;

wx.showActionSheet({

itemList: [‘拍照’, ‘从手机相册选择’],

success(res){

if (res.tapIndex == 0){

}

else if (res.tapIndex == 1){

that.chooseImageFromPhotoAlbum();

}

},

})

}

chooseImageFromPhotoAlbum()

{

var that = this;

wx.chooseImage({

count: 3 - that.data.uploaderNum, // 默认9

sizeType: [‘original’, ‘compressed’], // 可以指定是原图还是压缩图,默认二者都有

sourceType: [‘album’, ‘camera’], // 可以指定来源是相册还是相机,默认二者都有

success: function (res)

{

let tempFilePaths = res.tempFilePaths;

let uploaderList = that.data.uploaderList.concat(tempFilePaths);

}

that.setData({

uploaderList: uploaderList,

uploaderNum: uploaderList.length,

})

},

})

},

2 回复

请忽略代码中的标点错误…

回到顶部