vue 将图片流转换为 base64 的图片 src
getVerify() { let that = this; axios({ method: "GET", url: `http://192.168.7.61:3000/base/BaseApiService/createCaptchaCode?access_token=bjcenter`, responseType: "arraybuffer", //这个在请求头里必须加 }) .then((res) => { return ( "data:image/png;base64," + btoa( new Uint8Array(res.data).reduce( (data, byte) => data + String.fromCharCode(byte), "" ) ) ); }) .then((res) => { that.verify = res; console.log("res", res); }) .catch((e) => { console.log(e); }); },
越努力越幸运