下载微信图片,微信小程序保存图片到本地
转载:wx.getImageInfo({src:'https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/logo_white_fe6da1ec.png',success:function(ret){varpath=ret.path;wx.saveImageToPhotosAlbum({filePath:path,success(result){console.log(result)}})}})保存之前先download一下,把返回的tempFilePath临时文件路径给wx.saveImageToPhotosAlbum的filePath参数wx.downloadFile({url:'https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/logo_white_fe6da1ec.png',success:function(res){wx.saveImageToPhotosAlbum({filePath:res.tempFilePath,success(result){console.log(result)}})wx.saveFile({tempFilePath:res.tempFilePath,success:function(res){console.log(res.savedFilePath)}})}})wx.getImageInfo({src:'../images/shareimg.jpg',success:function(res){console.log(res.path)wx.getSetting({success(res){if(!res.authSetting['scope.writePhotosAlbum']){wx.authorize({scope:'scope.writePhotosAlbum',success(){wx.saveImageToPhotosAlbum({filePath:res.path,success(result){console.log(result)}})}})}}})}})
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

