Get the App
SLTechnology News&Howtos  ›  Development  › 

How to transfer WeChat Mini Programs's picture to base64

Shulou Source: shulou.com Published: 2022-05-31 23:20:46 09月11日 Update

In this article, the editor introduces in detail the "WeChat Mini Programs picture pull how to base64", the content is detailed, the steps are clear, and the details are handled properly. I hope this "WeChat Mini Programs picture pull how to base64" article can help you solve your doubts.

Usage

Js file

Let $this = this;request ({url:' https://cache.yisu.com/upload/ask_collection/20210725/111/131488.jpg', method:'GET', responseType: 'arraybuffer', success:function (res) {let base64 = wx.arrayBufferToBase64 (res); $this.data.userImageBase64 = _' data:image/jpg;base64,' + base64;;}})

Wxml file

PS: the easiest way to convert Mini Program's local pictures to base64

Wx.chooseImage: get the image address

Wx.getFileSystemManager: create a file management class

ReadFileSync: read local files and get base64 directly

Wx.chooseImage ({success: function (res) {console.log (wx.getFileSystemManager (). ReadFileSync (res.tempFilePaths [0], "base64"))},}) here, the article "how to transfer the picture of WeChat Mini Programs to base64" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about the related articles, Welcome to the industry information channel.

Tags: Pictures procedures documents articles content methods proper usage addresses ideas new knowledge more steps knowledge knowledge points articles details industry information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft NVidia Docker Linux Shulou Information