Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to save WeChat Mini Programs's pictures

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

本篇内容介绍了"微信小程序图片怎么保存"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

具体操作步骤:

1.下载文件资源到本地:客户端直接发起一个 http get 请求,返回文件的本地临时路径。

即:调用函数wx.downloadfile({})

2.保存图片到系统相册。

即:调用函数wx.saveimagetophotosalbum({})

具体代码如下:

.wxml

保存图片

.js

saveimage: function (e) {

wx.downloadfile({

url: 服务器http请求 +图片路径,

success: function (res) {

var imagefilepath = res.tempfilepath;

if (!util.isnull(imagefilepath)) {

wx.saveimagetophotosalbum({

filepath: imagefilepath,

success: function (data) {

wx.showtoast({

title: "保存成功",

})

}, fail: function (res) {

wx.showtoast({

title: "保存失败",

})

}

})

}

},

})

},

"微信小程序图片怎么保存"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report