ion-img
Img 是一个标签,当标签在视口中时,它会延迟加载图像。这在生成大型列表时非常有用,因为图像仅在可见时才加载。该组件在内部使用 Intersection Observer,大多数现代浏览器都支持它,但在不支持时会回退到使用 setTimeout。
基本用法
属性
alt
| 说明 | 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. |
| 属性 | alt |
| 类型 | string | undefined |
| 默认值 | undefined |
src
| 说明 | The image URL. This attribute is mandatory for the <img> element. |
| 属性 | src |
| 类型 | string | undefined |
| 默认值 | undefined |
事件
| Name | 说明 | 冒泡 |
|---|---|---|
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 |
方法
该组件没有可用的公共方法。
CSS Shadow Parts
| Name | 说明 |
|---|---|
image | The inner img element. |
CSS 自定义属性
该组件没有可用的 CSS 自定义属性。
插槽
该组件没有可用的插槽。