2022-08-12记

2022-08-12 08:42 Friday1311min
CC BY 4.0(除特别声明和转载)

记录一下昨天 Viewerjs 的使用

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/viewerjs/1.10.5/viewer.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/viewerjs/1.10.5/viewer.min.js"></script>
<script type="text/javascript">
    var list = document.querySelectorAll("img");
    var imgCount = list.length;
    var imgNow;
    var viewer = [];
    if (imgCount > 2) {
        for (var i = 1; i < imgCount - 1; i++) //去除侧边栏头像和末尾咖啡
        {
            imgNow = list[i];
            //console.log(imgNow.src);
            viewer[i - 1] = new Viewer(imgNow);
        }
    }
</script>

引入后点击图片可弹出详情浮窗进行操作,默认剔除侧边栏头像和末尾打赏的图片浮窗效果。通过简陋的循环起止条件控制。

BuyMeACola