提交 32a7f45f 编写于 作者: Q qq_36110571

Auto Commit

上级 489b7e05
......@@ -8,10 +8,6 @@
<title>InsCode</title>
</head>
<body>
<div class="container">
<img src="src/assets/logo.svg" alt="InsCode">
<div>欢迎来到 InsCode</div>
</div>
<script src="script.js"></script>
<div id="imageBox" style="border:1px solid #d3d3d3;width:50px;height:auto;overflow: hidden;">111</div>
</div>
......
window.onload = () => {
let total = 50;
const imageBox = document.getElementById('imageBox');
const imageUrls = Array.from(
{length: total},
() => "https://yx5679.com/uploads/20241015/bce93d85b7455ff15a68ae539d61400a.jpg?t=" + Date.now()
);
// console.log(imageUrls);
function fetchImage(url) {
return fetch(url)
.then(response => {
if (!response.ok) {
throw new Error(`Failed to fetch ${url}: ${response.status}`);
}
return response.blob();
})
.catch(error => {
console.error(error);
return null; // 或者返回一个默认的图片
});
}
function loadImages(urls) {
return Promise.all(urls.map(fetchImage))
.then(images => {
// 处理加载完成的图片
images.forEach((imageBlob, index) => {
// console.log(index);
if (imageBlob) {
const imgElement = document.createElement('img');
imgElement.src = URL.createObjectURL(imageBlob);
!index && imageBox.appendChild(imgElement);
}
});
})
.catch(error => {
console.error('Error loading images:', error);
});
}
loadImages(imageUrls);
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册