Skip to content

Image

Enhanced image display with multiple fit modes and lazy loading.

Examples

Fit modes

Stretch to fill
scaleToFill
Fit inside
aspectFit
Cover
aspectFill

Image fit

Use the `mode` prop to control how the image fits its box

Lazy loading

lazy-load
lazy-load

Lazy loading

With `lazy-load`, images load when they enter the viewport

API

Props

属性说明类型默认值
srcImage URLstring-
modeFit / scale modestringscaleToFill
lazy-loadWhether to lazy loadbooleanfalse

mode values

ValueDescription
scaleToFillStretch to fill the box (may distort)
aspectFitScale uniformly; show the full image (may letterbox)
aspectFillScale uniformly; crop to fill
widthFixFixed width; height follows aspect ratio
heightFixFixed height; width follows aspect ratio
top / bottom / center / left / rightNo scaling; align and crop to position

Events

属性说明类型默认值
loadFired when the image loads successfully{ width, height }-
errorFired when the image fails to load{ src }-

MiniDev Studio — Mini-app Development Toolkit