// 图片长按点击事件
imgBoxClick() {
console.log("长按触发");
console.log("httpImgUrl", this.httpImgUrl);
// 假设你有一个网络图片的链接
let imageUrl = this.httpImgUrl;
// 下载图片
uni.downloadFile({
url: imageUrl,
success: downloadResult => {
if (downloadResult.statusCode === 200) {
// 下载成功,保存图片到系统相册
uni.saveImageToPhotosAlbum({
filePath: downloadResult.tempFilePath,
success: () => {
uni.showToast({
title: '图片保存成功'
});
},
fail: () => {
uni.showToast({
title: '图片保存失败',
icon: 'none'
});
}
});
} else {
uni.showToast({
title: '图片下载失败',
icon: 'none'
});
}
},
fail: () => {
uni.showToast({
title: '图片下载失败',
icon: 'none'
});
}
});
},
uniapp下载图片到本地
猜你喜欢
转载自blog.csdn.net/m0_73505556/article/details/137924496
今日推荐
周排行