export const chooseImage = (count=9) => {
return new Promise((resolve,reject) => {
uni.chooseImage({
count, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera '], //从相册选择
success: async (res) => {
/* 压缩 H5不支持压缩 */
// #ifdef !H5
for (let index in res.tempFiles) {
if(res.tempFiles[index].size>200*1000){//大于200KB压缩
let cImg = await compressImage(res.tempFiles[index].path,80)
console.log(cImg)
if(cImg.err) continue
res.tempFiles[index].path = cImg.tempFilePath
}
}
// #endif
resolve(res.tempFiles)
},
fail(err) {
uni.hideLoading()
reject(err)
}
});
})
}
- 发布:2021-11-05 22:03
- 更新:2021-11-08 14:21
- 阅读:883
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: window10 家庭中文版 10.0.18363
HBuilderX类型: 正式
HBuilderX版本号: 3.2.9
第三方开发者工具版本号: 1.05.2108130
基础库版本号: 2.0.0
项目创建方式: HBuilderX
示例代码:
操作步骤:
1、写上按钮,添加点击事件
2、在点击事件中调用uni.chooseImage,并将sourceType设置为 ['album', 'camera ']
1、写上按钮,添加点击事件
2、在点击事件中调用uni.chooseImage,并将sourceType设置为 ['album', 'camera ']
预期结果:
ios可以调起摄像头拍照
ios可以调起摄像头拍照
实际结果:
ios无法调起摄像头拍照
ios无法调起摄像头拍照
bug描述:
uni.chooseImage 在微信小程序 ios12,微信版本8.0.14 无法调起摄像头
1 个回复
DCloud_UNI_Anne
直接使用微信小程序(不使用 uni-app )测试一下,如果仍然有问题,反馈到微信小程序社区