管理系统中,头像图片后台返回的是二进制流,
后台返回结果处理:
getUserPhoto().then((response) => {
let bytes = new Uint8Array(response);
let storeData = "";
let len = bytes.byteLength;
for (let i = 0; i < len; i++) {
storeData += String.fromCharCode(bytes[i]);
}
this.imageUrl = "data:image/png;base64," + window.btoa(storeData);
});
代码
网友评论