function layzload() {
var images = document.getElementsByTagName('img')
var len = images.length
var n = 0
return function(){
var seeHeight = document.documentElement.clientHeight
for(var i = n; i<len; i++){
if(iamges[i].getBoundingClientRect().top < seeHeight){
if(images[i].getAttribute('src') === 'images/default.jpg'){
images[i].src = images[i].getAttribute('data-src')
}
n = n+1
}
}
}
}
图片懒加载原理
最新推荐文章于 2022-08-23 16:09:05 发布