uniapp中webview内嵌H5页面图片保存方法~ |
您所在的位置:网站首页 › 如何网页保存视频到手机相册 › uniapp中webview内嵌H5页面图片保存方法~ |
废话不多说,直接贴代码~ var imgUrl = "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png"; var down = plus.downloader.createDownload(imgUrl, {}, function(e, a) { console.log(e); plus.gallery.save(e.filename,function (e) { uni.showToast({ title: "保存成功", mask:true , }); console.log("下载成功"); },function (e) { console.log("下载失败,请重试"); }) }); down.start();亲测可用!兼容安卓和iOS~ 如果是uniapp开发的H5页面里面的图片保存到手机相册,那就不用这么麻烦了。默认就支持长按图片保存~ 另外如果是在uniapp开发的APP中保存图片,那文档里直接有方法的: uni.downloadFile({ //下载图片 url:'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', success:(res)=>{ console.log(res.tempFilePath) uni.saveImageToPhotosAlbum({ //将图片保存在手机 filePath:res.tempFilePath, //保存的位置 success: (res) => { uni.showToast({ title: "图片已保存", mask:true , }); } }) } })本贴介绍的方法,仅仅用于将H5页面内嵌到uniapp的webview中,需要保存图片到手机相册的情况!! |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |