uni-app 前端 vue APP保存图片到相册
downLoad(){var timestamp = (new Date()).valueOf();var downLoader = plus.downloader.createDownload(this.img, {method: 'GET',filename: '_downloads/image/' + timestamp + '.png'
·
downLoad(){
var timestamp = (new Date()).valueOf();
var downLoader = plus.downloader.createDownload(this.img, {
method: 'GET',
filename: '_downloads/image/' + timestamp + '.png'
}, function(download, status) {
console.log(status)
if(status==200){
var fileName = download.filename;
/**
* 保存至本地相册
*/
console.log(fileName)
plus.gallery.save(fileName, function() {
uni.showToast({
icon:'success',
title:'保存二维码图片成功',
})
},function(){
uni.showToast({
icon:'success',
title:'保存失败,请重试',
})
});
}else{
uni.showToast({
icon:'success',
title:'下载失败,请重试',
})
}
});
downLoader.start();
},
更多推荐
已为社区贡献2条内容
所有评论(0)