在我的javascript文件中传播不可交互示例的尝试无效?

qxsslcnc  于 2021-09-08  发布在  Java
关注(0)|答案(0)|浏览(179)

我得到以下错误:

new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a

我的代码:

(() => {
    let images = [...document.querySelectorAll('[data-src]')];

    const settings = {
        rootMargin: '0px',
        threshold: 0.01
    };

    let observer = new IntersectionObserver((imageEntites) => {
        imageEntites.forEach((image) => {
            if (image.isIntersecting) {
                observer.unobserve(image.target);
                image.target.src = image.target.dataset.src;
                image.target.onload = () =>
                    image.target.classList.add('loaded');
            }
        });
    }, settings);

    images.forEach((image) => observer.observe(image));
})();

我正在使用最新的核心js和Babel。
想知道我的代码有什么问题,因为当我在开发模式下运行它时,它会工作。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题