undefinedfix
Sign in

How can I turn the QR code returned from the back end into a picture?

Hodgekins edited in Mon, 03 Oct 2022

clipboard.png

As shown in the figure, how to turn the front end?

6 Replies
user2964078
commented on Mon, 03 Oct 2022
html:
<img v-if="url" :src="url">

js:
var blob = new Blob(qrcode)
this.url = URL.createObjectURL(blob)

QRcode is the value returned to you by the background

w3Develops
commented on Mon, 03 Oct 2022

< img SRC = "you can take a screenshot of the URL path of this interface" ALT = >

Amsmsm
commented on Mon, 03 Oct 2022

Don't use it as an interface, it's just a picture, just no suffix. If the back end makes an interface again, it returns {"pic":“ http://xxxxx.com/inquiry "} you must be able to use it

SFMuscle
commented on Tue, 04 Oct 2022

The background returns a binary stream, which is encapsulated as a blob

if (window.URL.createObjectURL) {
  let blob = new Blob(response.data);
  let url = window.URL.createObjectURL(blob)
  this.qr_url = url;
} 
gembleng
commented on Tue, 04 Oct 2022

Assumption: interface address: http :// localhost / Inquiry at this time should not use ajax to request to change the address, just assign it to the SRC of img < img src =" http :// localhost / Inquiry & quot ; />

There is another problem, that is, the browser will cache the image, so the QR code may have changed, but the latest QR code cannot be displayed normally, so a random number is usually added after the URL < img src =" http :// localhost / Inquirey ?_=...; />

Smit
commented on Tue, 04 Oct 2022

I'm sorry, all of you, I've turned to the link to return