Skip to content

Image 图片

基本用法

INFO

使用object-fit指定图像如何适应容器的高度和宽度

图片预览

图像加载中/加载失败

INFO

使用slot="loading"slot="failed"自定义图像加载中、加载失败后的显示

展示头像

INFO

可以通过roundedradius来显示头像,rounded的优先级高于radius

图片懒加载

INFO

可以通过lazy属性来开启懒加载,如果lazylazyOptions.useIntersectionObserver均为true,则使用IntersectionObserver API;反之则使用img标签原生loading

API

Drawer Props

参数名说明类型可选值默认值
previewSrc预览的图片 URL,未提供则使用srcstring
preview是否开启预览booleanfalse
width图片原生width属性,指定width/height可以让浏览器预留位置加载图片,避免布局发生大的变化string / number0
height图片原生height属性string / number0
lazy是否开启懒加载booleanfalse
animated是否开启动画效果booleantrue
lazyOptions懒加载参数LazyOptions
objectFit同 css object-fit 属性stringfill / contain / cover / sacle-down / none'fill'
showToolbar是否显示预览的工具栏booleantrue
showLoading是否开启loading效果booleantrue
rounded是否圆形(显示为头像)booleanfalse
radius圆角大小(50%时的效果等同于rounded),当roundedtrue时,忽略本参数string / number0

LazyOptions

参数名说明类型可选值默认值
useIntersectionObserver是否使用 IntersectionObserver API 代替原生 loading 属性booleantrue
intersectionRootrootElement/Documnet/nullnull
intersectionRootMarginrootMarginstring'0px 0px 0px 0px'
intersectionThresholdthresholdsnumber / number[]0

Drawer Slots

插槽名说明子标签
failed自定义图片加载失败时的内容
loading自定义图片加载时的内容