uni.chooseImage({
count: data,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
let tempFilePaths = res.tempFilePaths
let list = []
tempFilePaths.forEach((cal,index) => {
uni.saveFile({
tempFilePath: cal,
success: function (ress) {
console.log(ress)
list.push(ress.savedFilePath)
if (list.length == res.tempFilePaths.length) {
res.tempFilePaths = list
return callback(res)
}
}
})
})
},
fail(ress) {
console.log(ress)
}
})
- 发布:2020-10-09 10:09
- 更新:2020-10-09 10:09
- 阅读:657
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 1909
HBuilderX类型: 正式
HBuilderX版本号: 2.8.13
手机系统: iOS
手机系统版本号: IOS 14
手机厂商: 苹果
手机机型: IPhone X
页面类型: vue
打包方式: 云端
项目创建方式: HBuilderX
App下载地址或H5⽹址: itms-apps://apps.apple.com/cn/app/%E8%87%AA%E4%BB%B7%E5%90%A7/id1513497137
示例代码:
操作步骤:
uni.chooseImage({
count: data,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
let tempFilePaths = res.tempFilePaths
let list = []
tempFilePaths.forEach((cal,index) => {
uni.saveFile({
tempFilePath: cal,
success: function (ress) {
console.log(ress)
list.push(ress.savedFilePath)
if (list.length == res.tempFilePaths.length) {
res.tempFilePaths = list
return callback(res)
}
}
})
})
},
fail(ress) {
console.log(ress)
}
})
uni.chooseImage({
count: data,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
let tempFilePaths = res.tempFilePaths
let list = []
tempFilePaths.forEach((cal,index) => {
uni.saveFile({
tempFilePath: cal,
success: function (ress) {
console.log(ress)
list.push(ress.savedFilePath)
if (list.length == res.tempFilePaths.length) {
res.tempFilePaths = list
return callback(res)
}
}
})
})
},
fail(ress) {
console.log(ress)
}
})
预期结果:
循环多次保存图片,全部成功
循环多次保存图片,全部成功
实际结果:
部分成功
部分成功
bug描述:
{
"errMsg": "saveFile:fail 保存文件[file:///var/mobile/Containers/Data/Application/E0CC3788-3A7F-436D-B8BF-A130091CB548/Documents/Pandora/apps/DF70A1E5E80D4FFE03EA310A60CE997A/doc/uniapp_temp_1602208268299/gallery/1588213604-IMG_0018.PNG] copyTo 失败:无效的修改"
}
0 个回复