专栏"图片"在MYSQL中有LONGBLOB数据类型。 JSON将图像解析为BLOB。我想在图像中使用图像src =""
var selectLapbooks = function () {
var request = new XMLHttpRequest();
request.open("GET", "SelectLapbook", false);
request.send();
if (request.status === 200) {
var response = request.responseText;
var lapbooks = JSON.parse(response);
var element = document.getElementById("lapbooks");
element.innerHTML = "";
for (var i = 0; i < lapbooks.length; i++) {
var img = new Image();
img.src = window.URL.createObjectURL(new Blob([lapbooks[i].picture]));
element.innerHTML +=
"<a href='#'><img class='card-img-top' src='"+img.src+"' alt=''></a>";
}
}
};
图片中的数据