Skip to content

Image

This component is based on the uni-app image component with secondary encapsulation, enhancing image display capabilities. Key features include:

  • Supports Lazy Load and Fade-in Animation
  • Supports Custom Border Radius and Mask Layer
  • Supports Image Preview mode
  • Supports placeholders for Load Failed and Loading
  • Supports Default Slot for custom overlay content

Platform Differences

App(vue)App(nvue)H5Mini Program

Basic Usage

  • Set the image resource URL via src.
  • Set width and height via width and height (supports CSS units like px, %).
html
<see-image src="https://www.seeuui.cn/logo.png" width="80px" height="80px" />

Border Radius

  • Set the image border radius via the radius property, in px.
html
<see-image
  src="https://www.seeuui.cn/logo.png"
  width="80px"
  height="80px"
  :radius="40"
/>

Mask Layer

  • Set showMask to true to enable the mask layer.
  • maskColor: Custom mask color.
  • maskOpacity: Custom mask opacity (0-1).
  • Commonly used for image selection states or darkening background images.
html
<see-image
  src="..."
  showMask
  maskColor="#000"
  :maskOpacity="0.3"
/>

<see-image
  src="..."
  showMask
  maskColor="#3ca7ff"
  :maskOpacity="0.4"
/>

Image Preview

  • When previewMode is enabled, clicking the image triggers a preview (usually for viewing the large image).
  • Can be combined with preview-tip to set hint text (used in some scenarios).
html
<see-image
  src="https://www.seeuui.cn/logo.png"
  width="200px"
  height="200px"
  previewMode
  preview-tip="Click to view large image"
/>

Animation and Lazy Load

  • lazyLoad: Enable image lazy loading (loads only when scrolled into the viewport).
  • fadeInDuration: Set the fade-in animation duration (ms) after the image loads successfully. Default is 300ms.
  • loading-text: Set placeholder text during loading.
html
<see-image src="..." :fadeInDuration="100" />

<see-image src="..." :lazyLoad="true" loading-text="Loading..." />

Custom Content (Slot)

  • The component provides a default slot, and child elements will be overlaid on top of the image.
  • Combined with showMask, it is easy to achieve a "Image + Text Title" card effect.
html
<see-image src="..." width="200px" height="200px" showMask :maskOpacity="0.4">
  <view class="custom-content" style="color: #fff; text-align: center;">
    <text>Custom Title</text>
  </view>
</see-image>

Error Handling

  • Listen to the onError event to capture load failures, usually used to replace the default image or log statistics.
html
<see-image src="https://invalid-url.com/err.jpg" @onError="handleImageError"
/>

API

Props

ParameterDescriptionTypeDefaultOptionsPlatform Diff
srcImage resource URLString''--
widthImage widthString / Number'100%'Any CSS unit-
heightImage heightString / Number'auto'Any CSS unit-
modeImage cropping/scaling modeString'scaleToFill'Refer to uni-app image mode-
radiusBorder radius size (px)Number0--
showMaskWhether to show the mask layerBooleanfalsetrue, false-
maskColorMask layer colorString'#000'Any CSS color-
maskOpacityMask layer opacityNumber0.50 ~ 1-
lazyLoadWhether to enable lazy loadingBooleanfalsetrue, false-
loadingTextText displayed during loadingString''--
fadeInDurationFade-in duration after image load success (ms)Number300--
previewModeWhether to enable click-to-preview modeBooleanfalsetrue, false-
previewTipHint text in preview modeString''--

Events

Event NameDescriptionCallback ParamsPlatform Diff
onClickTriggered when image is clicked--
onLongpressTriggered when image is long-pressed--
onLoadTriggered when image load is completeevent-
onErrorTriggered when image load failsevent-

Slots

Slot NameDescription
defaultCustom content above the image (e.g., text, icons), often used with mask layer

Liao ICP No. 2025070134