Skip to content

虚拟表格

ant-design-vue 风格虚拟表格。

安装

bash
$ npm install @vue-virtual-components/antd-table
bash
$ pnpm add @vue-virtual-components/antd-table
bash
$ yarn add @vue-virtual-components/antd-table

基本用法

简单的表格,最后一列是各种操作。

完整用法

复杂的表格,展示表格目前支持的各种用法。

API

Table

参数说明类型默认值
tableStyle表格风格antd | antd2antd
bordered是否展示外边框和列边框booleanfalse
columns表格列的配置描述,具体项见下表array-
data数据数组object[][]
getPopupContainer设置表格内各类浮层的渲染节点,如筛选菜单(triggerNode) => HTMLElement-
loading页面是否加载中booleanfalse
locale默认文案设置,目前包括筛选、排序、空数据文案objectemptyText: '暂无数据',
selectionNone: '清空所有',
selectionInvert: '反选当页',
selectionAll: '全选所有',
triggerDesc: '点击降序',
triggerAsc: '点击升序',
cancelSort: '取消排序'
rowClassName表格行的类名string | Function(record, index):string-
rowKey表格行 key 的取值,可以是字符串或一个函数string | Function(record):string'id'
rowSelection列表项是否可选择,配置项object-
scroll表格是否可滚动,也可以指定滚动区域的宽、高,配置项object-
showSorterTooltip表头是否显示下一次排序的 tooltip 提示。当参数类型为对象时,将被设置为 Tooltip 的属性boolean | Tooltip propstrue
size表格大小default | middle | smalldefault
tableLayout表格元素的 table-layout 属性,设为 fixed 表示内容不会影响列的布局auto | fixedfixed

事件

参数说明回调参数
change排序变化时触发Function({ currentDataSource, sorter })

Column

列描述数据对象,是 columns 中的一项,Column 使用相同的 API。

参数说明类型默认值
headerSlot个性化头部单元格v-slot:[headerSlot]="{ column }"-
slot个性化单元格v-slot:[slot]="{text, record, index, column}"取值优先级:slot || key
align设置列的对齐方式left | right | centerleft
colSpan表头列的colspannumber-
rowSpan表头列的rowspannumber-
customHeaderCell设置头部单元格属性Function(column)-
dataIndex列数据在数据项中对应的路径,支持通过数组查询嵌套路径string | string[] | number-
defaultSortOrder默认排序顺序ascend | descend | false-
fixed列是否固定left | right-
keyVue 需要的 keystring-
minWidth列最小宽度number-
showSorterTooltip表头显示下一次排序的 tooltip 提示, 覆盖 table 中 showSorterTooltipboolean | Tooltip props-
sorter排序函数,本地排序使用一个函数(参考 Array.sort 的 compareFunction),需要服务端排序可设为 trueFunction | boolean-
sortOrder排序的受控属性,外界可用此控制列的排序,可设置为 'ascend' 'descend' falseboolean | string-
title列头显示文字string-
width列宽度number-

RowSelection

选择功能的配置。

参数说明类型默认值
fixed把选择框列固定在左边boolean-
getCheckboxProps选择框的默认属性配置Function(record)-
hideSelectAll隐藏全选勾选框与自定义选择项booleanfalse
selectedRowKeys指定选中项的 key 数组,需要和 onChange 进行配合string[][]
selections自定义选择项 配置项, 设为 true 时使用默认选择项object[] | booleantrue
type多选/单选,checkbox or radiostringcheckbox
onChange选中项发生变化时的回调Function(selectedRowKeys, selectedRows)-
onSelect用户手动选择/取消选择某列的回调Function(record, selected, selectedRows, nativeEvent)-
onSelectAll用户手动选择/取消选择所有列的回调Function(selected, selectedRows, changeRows)-
onSelectInvert用户手动选择反选的回调Function(selectedRows)-
onSelectNone用户清空选择的回调Function()-

Scroll

参数说明类型默认值
x设置横向滚动,也可用于指定滚动区域的宽,可以设置为像素值,百分比,true 和 'max-content'string | number | true -
y设置纵向滚动,也可用于指定滚动区域的高,可以设置为像素值string | number-

Selection

自定义选择配置项

参数说明类型默认值
keyVue 需要的 key,建议设置string-
text选择项显示的文字string | VNode-
onSelect选择项点击回调Function(changeableRowKeys)-

Released under the MIT License.