Skip to content

Image 图片

Image 组件是一个增强的图片显示组件,提供了模糊加载、缩放、骨架屏等功能,为用户提供更好的图片浏览体验。

引入

typescript
import { Image } from '@versakit/vue'

使用

loading

API

属性

属性名说明类型默认值
src图片源地址string-
alt图片加载失败时的替代文本string''
width图片宽度string | number'auto'
height图片高度string | number'auto'
fit图片填充模式'fill' | 'contain' | 'cover' | 'none' | 'scale-down''cover'
blurred是否启用模糊加载效果booleanfalse
blurAmount模糊加载的模糊度number10
loading图片加载策略'lazy' | 'eager''lazy'
isZoomable是否启用缩放功能booleanfalse
isZoomed是否当前处于缩放状态booleanfalse
zoomScale缩放比例number1.5
skeleton是否显示骨架屏booleantrue
skeletonColor骨架屏背景色string-
radius图片圆角'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full''md'
unstyled是否禁用默认样式booleanfalse
pt自定义样式传递ImagePT-

事件

事件名说明回调参数
load图片加载成功时触发(event: Event) => void
error图片加载失败时触发(event: Event) => void
zoom图片缩放状态变化时触发(zoomed: boolean) => void

插槽

插槽名说明
default默认插槽,通常不需要使用
error图片加载失败时显示的内容
zoom-icon缩放图标的自定义内容

样式定制

可以通过 pt 属性传递自定义样式:

vue
<Image
	src="..."
	:pt="{
		root: 'custom-root-class',
		img: 'custom-img-class',
		skeleton: 'custom-skeleton-class',
		overlay: 'custom-overlay-class',
	}"
/>