首页 > 移动平台 > 详细

uniapp保存网络图片到相册

时间:2020-07-07 17:47:49      阅读:755      评论:0      收藏:0      [点我收藏+]
//下载网络图片
    saveHttpImg(url){
    let _t = this;
       uni.downloadFile({
                        url:url, //仅为示例,并非真实的资源
                        success: (res) => {
                                if (res.statusCode === 200) {
                                        let file = res.tempFilePath;
                                        _t.save(file)
                                }
                        }
                });
            },
//保存图片到本地
            save(url){
              let _this = this;
                _this.$util._loading("保存中...");
                uni.saveImageToPhotosAlbum({
                    filePath: url,
                    success: () => {
                        uni.hideLoading();
                        _this.$util._toast("图片已保存");
                    },
                    fail: () => {
                        uni.hideLoading();
                        _this.$util._toast("保存失败");
                    },
                    complete: () => {
                    
                    }
                });
          },

uniapp保存网络图片到相册

原文:https://www.cnblogs.com/jyc226/p/13261587.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!