Skip to content

ImageGrid 图片网格

介绍

网格布局展示图片,可等比宽高展示、自定义一行展示数量。

基础用法

通过 images 属性来设置图片列表。

html
<vd-image-grid :images="images" />
ts
const images = ref([...]);

一行展示列数

通过 columns 属性来设置一行展示的列数。

html
<vd-image-grid :images="images" :columns="4" />
ts
const images = ref([...]);

自定义高宽,行/列间距

通过 height 属性来设置图片高度,row-gap 属性来设置行间距,column-gap 属性来设置列间距。

TIP

height 传入百分比的值,将认为是相对宽度的比例,如 20% = width * 0.2

html
<vd-image-grid
  :images="images"
  height="80"
  row-gap="16"
  column-gap="16"
/>
ts
const images = ref([...]);

API

Props

参数说明类型默认值
columns列数string | number3
height高度string | number'100%'
radius边框半径string | number4
row-gap行间距string | number8
column-gap列间距string | number8
grid-transition载入动画TransitionName'none'
grid-transition-duration载入动画持续时间TransitionDuration400
sortable是否可拖拽排序booleanfalse
sort-target是否展示排序目标占位booleanfalse
images图片列表string[]-
mode图片裁剪、缩放的模式ImageMode'scaleToFill'
icon-size加载中、加载错误图标大小string | number-
loading-type加载中类型,同 loading 组件LoadingType-
preview是否展示图片预览booleantrue
preview-name图片预览名称,指定已有的图片预览,不指定使用当前组件内部的图片预览string-

代替原始 Props

参数说明类型默认值
custom-id根节点idstring-
custom-class根节点类名ClassValue-
custom-style根节点样式StyleValue-

Events

事件名说明回调参数
click点击时触发MouseEvent
click-view点击视图时触发ImageGridOnClickViewEvent
resize尺寸更新时触发NodeSize
sort-start排序开始时触发ImageGridOnSortStartEvent
sort-change排序改变时触发ImageGridOnSortChangeEvent
sort-end排序结束时触发ImageGridOnSortEndEvent

Slots

名称说明
view图片视图

赣ICP备2025061025号-1