uniapp实现批量下载图片功能的代码
2023-06-02 本文已影响0人
xueyueshuai
let imageUrls = [
'https://image1.jpg',
'https://image2.jpg',
'https://image3.jpg',
// ...
];
for (let i = 0; i < imageUrls.length; i++) {
uni.downloadFile({
url: imageUrls[i],
success: (res) => {
if (res.statusCode === 200) {
uni.saveFile({
tempFilePath: res.tempFilePath,
success: (res) => {
console.log('图片已保存到:' + res.savedFilePath);
}
});
}
}
});
}