<image :src="imgVerificationCode" @click="getVerificationCode" class="imageCode"></image>
arrayBufferToBase64(buffer) {
var binary = '';
var bytes = new Uint8Array(buffer);
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
},
getVerificationCode() { uni.request({ url: 'http://127.0.0.1:9090/code/image', header: { 'content-type': 'application/x-www-form-urlencoded', 'deviceId':'xrl1334' }, responseType:'arraybuffer', method: 'GET', data: { "width": 60 }, success: (res) => { console.log("imageCodeUrl",res) var url= this.arrayBufferToBase64(res.data); console.log('url',url) this.imgVerificationCode ='data:image/jpeg;base64,'+url; }} ) },
标签:binary,url,res,app,bytes,验证码,var,uni,data From: https://www.cnblogs.com/xiaoruilin/p/16717477.html