When WeChat Mini Programs gets the QR code, what is returned is a large string of garbled codes. How to parse the garbled codes into QR codes? I want to display them on the interface.

clipboard.png

Mar.29,2021

write
< image src= "data:image/png;base64, {{imgUrl}}" / >

on the component page

in the place where the res.data is obtained through ACCESS_TOKEN (where the pile of garbled codes above), pay attention to adding:
responseType:'arraybuffer',

in the request part.

after success obtains res.data
self.imgUrl=wx.arrayBufferToBase64 (res.data);


what Wechat gives you is the binary data of the picture

  1. you save this data as a picture on the server, and then you return the url, of this picture to Mini Program to display

  2. you base64 this data, then give it to Mini Program, and then display

  3. through src= " data:image/png;base64, picture base64 data ".

I solved it after referring to this link. I'm more excited. Share it. https://codeshelper.com/a/11.


can you be more detailed?
look at the data section, it seems to be a picture, because there are a lot of indescribable characters in the picture, so what you see is garbled.
it's like opening a picture in notepad, okay?
can I give a URL or http request header?


< image src= "Wechat QR Code address" / >

Menu