ion-img

概要(CONTENTS)

Ionic4项目中我们可以使用Ionic4媒体组件ion-img对项目进行布局。ion-img中有ionic ion-img 用法(Usage) ,ionic ion-img 属性(Properties) ,ionic ion-img 事件(Events)等

Img is a tag that will lazily load an image when ever 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 browser, but falls back to a setTimeout when it is not supported.

ion-img 用法(Usage)

angular
<ion-list>
  <ion-item *ngFor="let item of items">
    <ion-thumbnail slot="start">
      <ion-img [src]="item.src">ion-img>
    ion-thumbnail>
    <ion-label>{{item.text}}ion-label>
  ion-item>
ion-list>

ion-img 属性(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

src

Description

The image URL. This attribute is mandatory for the element.

Attribute src
Type string | undefined

ion-img 事件(Events)

Name Description
ionImgDidLoad Emitted when the img src is loaded