This commit is contained in:
@fawn-nine
2024-07-05 16:43:05 +08:00
parent c6d567c13a
commit e94bebaf35
6 changed files with 444 additions and 5 deletions

25
src/utils/imgPre.js Normal file
View File

@@ -0,0 +1,25 @@
var modal = document.getElementById("modal");
var modalImg = document.getElementById("modalImage");
var images = document.querySelectorAll(".zoomable");
// 遍历为每个图片元素添加事件监听器
images.forEach(function (image) {
image.addEventListener("click", function () {
modal.style.display = "block";
modalImg.src = this.src;
});
});
var span = document.querySelector(".close");
span.addEventListener("click", function () {
modal.style.display = "none";
});
modal.addEventListener("click", function (event) {
if (event.target == modal) {
modal.style.display = "none";
}
});