ion-img
Img 是一个标签,只要标签位于视口中,就会延迟加载图片。这在生成大型列表时非常有用,因为图片仅在可见时才加载。该组件在内部使用 交集观察者,大多数现代浏览器都支持它,但在不支持时会回退到 setTimeout
。
¥Img is a tag that will lazily load an image whenever the tag is in the viewport. This is extremely useful when generating a large list as images are only loaded when they're visible. The component uses Intersection Observer internally, which is supported in most modern browsers, but falls back to a setTimeout
when it is not supported.
基本用法
¥Basic Usage
属性
¥Properties
alt
Description | This attribute defines the alternative text describing the image. Users will see this text displayed if the image URL is wrong, the image is not in one of the supported formats, or if the image is not yet downloaded. |
Attribute | alt |
Type | string | undefined |
Default | undefined |
src
Description | The image URL. This attribute is mandatory for the <img> element. |
Attribute | src |
Type | string | undefined |
Default | undefined |
事件
¥Events
Name | Description | Bubbles |
---|---|---|
ionError | Emitted when the img fails to load | true |
ionImgDidLoad | Emitted when the image has finished loading | true |
ionImgWillLoad | Emitted when the img src has been set | true |
方法
¥Methods
No public methods available for this component.
CSS 阴影部分
¥CSS Shadow Parts
Name | Description |
---|---|
image | The inner img element. |
CSS 自定义属性
¥CSS Custom Properties
No CSS custom properties available for this component.
插槽
¥Slots
No slots available for this component.