WeChat Mini Programs's sample code that cannot be displayed in Base64 pictures.
This article mainly introduces WeChat Mini Programs Base64 pictures can not show the sample code, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Wx.request is used to send requests in Mini Program, the Base64 stream is returned by the background, and the foreground is displayed with tags.
WeChat Mini Programs's Base64 picture does not display the abbreviated code as follows:
Filetfile=newFile ("/ Users/sam/Downloads/test.jpg")
FileInputStreamfileInputStream=newFileInputStream (tfile)
Byte [] buffer=newbyte [fileInputStream.available ()]
FileInputStream.read (buffer)
FileInputStream.close ()
BASE64Encoderbase64Encoder=newBASE64Encoder ()
StringencodedStr=base64Encoder.encode (buffer)
OutputStream.write (encodedStr.getBytes ())
OutputStream.close ()
Base64 pictures in js:
OnSubmit:function (e) {
Varthat=this
Wx.request ({
Data: {
}
Method:'GET'
Header: {
'content-type':'application/json'
}
Success (res) {
That.setData ({ImageBase64Str:_'data:image/png;base64,'+res.data})
}
})
}
In wxml:
Thank you for reading this article carefully. I hope the article "sample Code that cannot be displayed in WeChat Mini Programs Base64 pictures" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!