1、html 二进制流 (非base64),给图片赋值
var reader = new FileReader();
reader.onload = function (e) {
var img = document.querySelector('#canvas_img');
img.src = e.target.result;
};
// data 二进流
reader.readAsDataURL(data);
2、
let canvas_img = document.querySelector('#canvas_img');
let imageType = "image/jpeg" ; //获取图片类型
let blob = new Blob([data] , { type: imageType });
let imageUrl = (window.URL || window.webkitURL).createObjectURL(blob);
canvas_img.setAttribute("src", imageUrl);
canvas_img.onload = function(e) {
window.URL.revokeObjectURL(canvas_img.src); //释放URL.createObjectURL()创建的对象
};