Skip to content

Commit

Permalink
fix:不能修改404的标签
Browse files Browse the repository at this point in the history
  • Loading branch information
theOnlyUnique committed Dec 29, 2024
1 parent 7ff9a91 commit 0573cf6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,18 @@ function setImgUrl(pageOfImages) {
console.log("更新时的数组", pageOfImages);
// 获取8个dom,将他们的src改变
let imgElements = document.getElementsByTagName("img");
let renameElements = document.getElementsByClassName("rename-btn");
// 遍历img标签
for (let i = 0; i < imgElements.length; i++) {
// 检查pageOfImages数组中是否有对应的图片
if (i < pageOfImages?.length ?? 0) {
// 如果有,则使用pageOfImages中的图片
imgElements[i].src = pageOfImages[i];
renameElements[i].disabled = false;
} else {
// 如果没有,则使用默认图片
imgElements[i].src = "./public/img/404.png";
renameElements[i].disabled = true;
}
}
}

0 comments on commit 0573cf6

Please sign in to comment.