IntersectionObserver懒加载
作者:互联网
const io = new IntersectionObserver(callback); let imgs = document.querySelectorAll('[data-src]'); function callback(entries){ entries.forEach((item) => { if(item.isIntersecting){ item.target.src = item.target.dataset.src io.unobserve(item.target) } }) } imgs.forEach((item)=>{ io.observe(item) })
标签:src,target,callback,item,io,entries,IntersectionObserver,加载 来源: https://www.cnblogs.com/vicky24k/p/12093278.html