Skip to content

KImage ​

Besides the native features of img, support lazy load, custom placeholder and load failure, etc.

Install ​

bash
pnpm add @ikun-ui/image
pnpm add @ikun-ui/image-view
bash
yarn add @ikun-ui/image
yarn add @ikun-ui/image-view
bash
npm install @ikun-ui/image
npm install @ikun-ui/image-view

Basic usage ​

Indicate how the image should be resized to fit its container by fit, same as native object-fit .

Placeholder ​

You can use the placeholder slot to define the placeholder content when the image is not loaded.

Load Failed ​

You can use the error slot to define the placeholder content when the image fails to load.

Lazy Load ​

The lazy loading function can be turned on through lazy, and the image will not be loaded until it is scrolled into the visible range.

Image Preview ​

The function of previewing large images can be enabled through previewSrcList

Image Props ​

NameTypeDefaultDescription
scrollContainerstring | HTMLElement""The container to add scroll listener when using lazy load. By default, the container to add scroll listener when using lazy load.
loading'eager' | 'lazy'""Indicates how the browser should load the image, same as native .
previewSrcListstring[][]Allow big image preview.
fit'fill' | 'contain' | 'cover' | 'none' | 'scale-down'""Indicate how the image should be resized to fit its container, same as object-fit .
srcstring""Image source, same as native.
altstring""Native attribute alt.
clsstring""Additional class for component
attrsany{}Additional attributes

Image Events ​

NameDescriptionType
loadsame as native load.(event: Event)=> void
errorsame as native error..(event: Event)=> void
showtrigger when the viewer displays.(event: Event)=> void

Image Slots ​

NameDescription
placeholdercustom placeholder content when image hasn't loaded yet.
errorcustom image load failed content.

ImageView Props ​

NameTypeDefaultDescription
showbooleanfalseWhether to display image preview
urlsstring[][]Preview image link list
clsstring""Additional class for component
attrsany{}Additional attributes

Image Events ​

NameDescriptionType
closetriggered when closed.(event: Event)=> void

MIT Licensed