一个用于 Angular 应用程序的懒加载图像的小库,无任何依赖
ng-lazyload-image 这是一个用于 Angular 应用程序的懒加载图像的超小型库,无任何依赖。
您要针对的浏览器需要支持 WeakMap 和 String.prototype.includes。如果需要支持旧版浏览器(如 IE),则需要包含 WeakMap 和 String.prototype.includes 的补丁(请参阅 https://github.com/zloirock/core-js 为例)。此外,如果需要针对 IE 并希望使用 IntersectionObserver,还需要包含 IntersectionObserver 的补丁。
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { LazyLoadImageModule } from 'ng-lazyload-image'; // ` elements.
There's no need to set `useSrcset` for `` elements, as `srcset` is used by default.
A simple example for a `` tag:
JavaScript @Component({ selector: 'image', 模板: ` ', }) class ImageComponent { screen_lg = '1200px'; screen_md = '992px'; defaultImage = 'https://www.placecage.com/1000/1000';' image1 = 'https://images.unsplash.com/photo-1422004707501-e8dad229e17a?fm=jpg'; image2 = 'https://images.unsplash.com/photo-1439931444800-9bcc83f804a6?fm=jpg'; image3 = 'https://images.unsplash.com/photo-1417128281290-30a42da46277?fm=jpg'; }
### 异步加载图像路径
您可以加载 im暂无开放 Issues,或尚未同步最近议题。