![](/img/trans.png)
[英]Lazy loading img's with IntersectionObserver polyfill fails in Internet Explorer
[英]IntersectionObserver undefined for Internet Explorer
我有一個 IntersectionObserver 來延遲加載圖像等,其中el
是 HTML 元素並offset
一個數字。
const observer = new IntersectionObserver((entries) => {
if (entries[0].isIntersecting === true) {
el.srcset = this.image;
observer.unobserve(el);
}
}, {threshold: [0], rootMargin: this.offset + 'px'});
observer.observe(el);
這個觀察者在每個瀏覽器上都能正常工作,但在 IE11 上卻不行。 調試它會返回以下錯誤:
“交叉口觀察者”未定義
這使得圖像根本不加載。 IE有解決方案嗎? 因為我認為 IE 不支持它,但正常行為不應該是最初執行觀察者的代碼嗎?
IE 不支持IntersectionObserver
。 你可以參考這篇文章。 如果你想在 IE 中支持它,你可以使用這個 polyfill 。 該庫在不支持的瀏覽器中填充原生IntersectionObserver
API。
InternetExplorer 不支持 IntersectionObserver。 您可以參考以下鏈接供您參考。 https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#Browser_compatibility
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.