处理后台返回的验证码图片,以文件流形式返回

747 阅读1分钟

this.http.
 get(
 `/sms/captcha.jpg?t={new Date().getTime()}`, {responseType: "arraybuffer",

}).then(res => {console.log(res.data )return 'data:image/png;base64,' + btoa(new Uint8Array(res.data).reduce((data, byte) => data + String.fromCharCode(byte), '') ) }) .then(data => {this.captcha = ''console.log(data)this.captchaPath = data}).catch(ex => {
console.error(ex);})