Table 表格
用于展示结构化二维数据,可以快速实对数据进行排序、搜索、分组、编辑、分页、汇总等操作。
代码示例#
First Name
Last Name
Job
Age
Email
First 0
Last 0
Good Job 0
20 (2006)
email0@vexip.ui
First 1
Last 1
Good Job 1
21 (2005)
email1@vexip.ui
First 2
Last 2
Good Job 2
22 (2004)
email2@vexip.ui
First 3
Last 3
Good Job 3
23 (2003)
email3@vexip.ui
First 4
Last 4
Good Job 4
24 (2002)
email4@vexip.ui
First Name
Last Name
Age
Job
Last 0
age: 20
Good Job 0
Last 1
age: 21
Good Job 1
Last 2
age: 22
Good Job 2
Last 3
age: 23
Good Job 3
Last 4
age: 24
Good Job 4
API#
预设类型#
Table 组件的类型定义非常之多,如果你想充分了解它们之间的关系,建议从 源码 入手。
ts
type Key = string | number | symbol
type Data = any
type TableIconName = 'filter' | 'asc' | 'desc' | 'dragger' | 'expand' | 'plus' | 'minus'
type TableRowPropFn<P = any> = (data: Data, index: number) => P
type TableRowDropType = 'before' | 'after' | 'none'
type TableTextAlign = 'left' | 'center' | 'right'
type TableColumnType = 'order' | 'selection' | 'expand' | 'drag'
type TableColResizeType = 'lazy' | 'responsive'
type TableIcons = Partial<Record<TableIconName, Record<string, any> | (() => any)>>
interface CellSpanResult {
colSpan?: number,
rowSpan?: number,
}
interface TableKeyConfig {
id?: string,
children?: string,
checked?: string,
height?: string,
expanded?: string,
treeExpanded?: string,
}
type Accessor<D = Data, Val extends string | number = string | number> = (
data: D,
index: number
) => Val
type ExpandRenderFn<D = Data> = (data: {
/** @deprecated */
leftFixed: number,
/** @deprecated */
rightFixed: number,
row: D,
rowIndex: number,
}) => any
type ColumnCellSpanFn<D = Data> = (data: {
row: D,
index: number,
fixed?: 'left' | 'right',
}) => CellSpanResult | undefined
type SummaryCellSpanFn<D = Data, Val extends string | number = string | number> = (data: {
column: TableColumnOptions<D, Val>,
index: number,
fixed?: 'left' | 'right',
}) => CellSpanResult | undefined
type TableFilterOptions<D = Data, Val extends string | number = string | number> =
| {
able?: boolean,
custom?: false,
options?: (string | { value: Val, label?: string, active?: boolean })[],
multiple?: false,
active?: null | Val,
method?: null | ((active: Val, data: D) => boolean),
meta?: any,
}
| {
able?: boolean,
custom?: false,
options?: (string | { value: Val, label?: string, active?: boolean })[],
multiple: true,
active?: null | Val[],
method?: null | ((active: Val[], data: D) => boolean),
meta?: any,
}
| {
able?: boolean,
custom: true,
options?: never,
multiple?: false,
active?: null | Val | Val[],
method?: null | ((active: any, data: D) => boolean),
meta?: any,
}
interface TableSorterOptions<D = Data> {
able?: boolean,
type?: null | 'asc' | 'desc',
order?: number,
method?: null | ((prev: D, next: D) => number),
}
interface TableSummaryData {
sum: number,
min: number,
max: number,
}
type SummaryRenderFn<D = Data, Val extends string | number = string | number> = (data: {
column: TableColumnOptions<D, Val>,
index: number,
rows: D[],
meta: TableSummaryData,
}) => any
type ColumnSummaryRenderFn<
D = Data,
Val extends string | number = string | number,
> = (data: {
column: TableColumnOptions<D, Val>,
index: number,
rows: D[],
meta: TableSummaryData,
summary: TableSummaryOptions<D, Val>,
}) => any
interface TableBaseColumn<D = Data, Val extends string | number = string | number> {
name: string,
key: keyof D,
type?: never,
meta?: any,
fixed?: boolean | 'left' | 'right',
class?: ClassType,
style?: StyleType,
attrs?: Record<string, any>,
width?: number,
filter?: TableFilterOptions<D, Val>,
sorter?: boolean | TableSorterOptions<D>,
order?: number,
/** @deprecated */
noEllipsis?: boolean,
ellipsis?: boolean,
textAlign?: TableTextAlign,
headSpan?: number,
noSummary?: boolean,
accessor?: Accessor<D, Val>,
formatter?: (value: Val) => unknown,
cellSpan?: ColumnCellSpanFn<D>,
renderer?: ColumnRenderFn<D, Val>,
headRenderer?: HeadRenderFn,
filterRenderer?: FilterRenderFn,
summaryRenderer?: ColumnSummaryRenderFn<D, Val>,
}
interface TableOrderColumn<D = Data, Val extends string | number = string | number>
extends Omit<TableBaseColumn<D, Val>, 'key' | 'type' | 'renderer'> {
key?: keyof D,
type: 'order',
truthIndex?: boolean,
orderLabel?: (index: number) => string | number,
}
interface TableSelectionColumn<D = Data, Val extends string | number = string | number>
extends Omit<TableBaseColumn<D, Val>, 'key' | 'type' | 'renderer' | 'headRenderer'> {
key?: keyof D,
type: 'selection',
selectionSize?: ComponentSize,
disableRow?: (data: Data) => boolean,
}
interface TableExpandColumn<D = Data, Val extends string | number = string | number>
extends Omit<TableBaseColumn<D, Val>, 'key' | 'type' | 'renderer'> {
key?: keyof D,
type: 'expand',
disableRow?: (data: Data) => boolean,
renderer?: ExpandRenderFn<D>,
}
interface TableDragColumn<D = Data, Val extends string | number = string | number>
extends Omit<TableBaseColumn<D, Val>, 'key' | 'type' | 'renderer'> {
key?: keyof D,
type: 'drag',
disableRow?: (data: Data) => boolean,
}
type TableTypeColumn<D = Data, Val extends string | number = string | number> =
| TableOrderColumn<D, Val>
| TableSelectionColumn<D, Val>
| TableExpandColumn<D, Val>
| TableDragColumn<D, Val>
type TableColumnOptions<D = Data, Val extends string | number = string | number> =
| TableBaseColumn<D, Val>
| TableTypeColumn<D, Val>
type ColumnWithKey<
D = Data,
Val extends string | number = string | number,
> = TableColumnOptions<D, Val> & { key: Key, rowSpan: number }
interface TableColumnGroupOptions {
name?: string,
fixed?: boolean | 'left' | 'right',
order?: number,
ellipsis?: boolean,
textAlign?: TableTextAlign,
renderer?: () => any,
children: TableColumnOptions<any, any>[],
}
type TableColumnRawOptions = TableColumnOptions<any, any> | TableColumnGroupOptions
type ColumnRenderFn<D = Data, Val extends string | number = string | number> = (data: {
row: D,
rowIndex: number,
column: TableBaseColumn<D, Val>,
columnIndex: number,
}) => any
type HeadRenderFn<D = Data, Val extends string | number = string | number> = (data: {
column: TableColumnOptions<D, Val>,
index: number,
}) => any
type FilterRenderFn<D = Data, Val extends string | number = string | number> = (data: {
column: TableColumnOptions<D, Val>,
index: number,
filter: Required<TableFilterOptions<D, Val>>,
handleFilter: (active: any) => void,
}) => any
type TableCellSpanFn<D = Data, Val extends string | number = string | number> = (data: {
row: D,
rowIndex: number,
column: TableColumnOptions<D, Val>,
columnIndex: number,
fixed?: 'left' | 'right',
}) => CellSpanResult | undefined
type TableCellPropFn<D = Data, P = any> = (data: {
row: D,
rowIndex: number,
column: ColumnWithKey,
columnIndex: number,
}) => P
type TableHeadPropFn<P = any> = (data: { column: ColumnWithKey, index: number }) => P
type TableFootPropFn<P = any> = (data: {
column: ColumnWithKey,
columnIndex: number,
summary: SummaryWithKey,
summaryIndex: number,
}) => P
type ColumnProfile<D = Data, Val extends string | number = string | number> = Pick<
ColumnWithKey<D, Val>,
'name' | 'key' | 'meta'
>
type TableFilterProfile<
D = Data,
Val extends string | number = string | number,
> = ColumnProfile<D, Val> & {
active: Val | Val[],
}
type TableSorterProfile<
D = Data,
Val extends string | number = string | number,
> = ColumnProfile<D, Val> & {
type: 'asc' | 'desc',
order: number,
}
interface TableSummaryOptions<D = Data, Val extends string | number = string | number> {
name: string,
key: keyof D,
class?: ClassType,
style?: StyleType,
attrs?: Record<string, any>,
order?: number,
above?: boolean,
cellSpan?: SummaryCellSpanFn<D, Val>,
renderer?: SummaryRenderFn<D, Val>,
}
type SummaryWithKey<
D = Data,
Val extends string | number = string | number,
> = TableSummaryOptions<D, Val> & { key: Key }
interface TableRowPayload {
row: Data,
key: Key,
index: number,
event: Event,
checked?: boolean,
expanded?: boolean,
}
interface TableCellPayload {
row: Data,
key: Key,
rowIndex: number,
column: TableColumnOptions,
columnIndex: number,
event: Event,
}
interface TableHeadPayload {
column: TableColumnOptions,
index: number,
event: Event,
}
interface TableColResizePayload extends TableHeadPayload {
width: number,
}
interface TableFootPayload {
column: TableColumnOptions,
columnIndex: number,
summary: TableSummaryOptions,
summaryIndex: number,
event: Event,
}
Table 属性#
| 名称 | 类型 | 说明 | 默认值 | 始于 |
|---|---|---|---|---|
| bar-fade | number | 设置滚动条的渐隐时间,若小于 300 则关闭渐隐效果 | 1500 | - |
| border | boolean | 设置表格是否具有外边框和纵向边框 | false | - |
| border-width | number | 设置表格的边框宽度 | 1 | 2.2.12 |
| cell-attrs | Record<string, any> | TableCellPropFn<Record<string, any>> | 单元格的自定义属性 | null | 2.0.1 |
| cell-class | ClassType | TableCellPropFn<ClassType> | 单元格的自定义类名 | null | 2.0.1 |
| cell-span | TableCellSpanFn | 设置单元格跨度的回调函数 | null | 2.1.24 |
| cell-style | StyleType | TableCellPropFn<StyleType> | 单元格的自定义样式 | null | 2.0.1 |
| col-resizable | boolean | TableColResizeType | 设置表格列的宽度是否可以调整,设置为 true 时等同于 'lazy' | false | 2.1.23 |
| columns | TableColumnRawOptions[] | 表格列的配置,参考下方的 TableColumn 属性 | [] | - |
| current-page | number | 设置表格当前显示的数据页 | 1 | - |
| custom-filter | boolean | 设置是否为自定义过滤,开启后仅派发事件而不会进行内部过滤 | false | 2.1.4 |
| custom-sorter | boolean | 设置是否为自定义排序,开启后仅派发事件而不会进行内部排序 | false | 2.1.4 |
| data | Data[] | 表格的数据源 | [] | - |
| data-filter | (data: Data) => boolean | 设置额外的数据过滤方法 | null | 2.2.14 |
| disabled-tree | boolean | 设置是否禁用自动解析树形数据 | false | 2.1.6 |
| ellipsis | boolean | 是否为单元格内容使用省略组件 | false | 2.2.16 |
| empty-text | string | 设置表格空数据时的提示语 | locale.empty | - |
| expand-renderer | ExpandRenderFn | 设置行拓展内容的渲染方法 | null | - |
| foot-attrs | Record<string, any> | TableFootPropFn<Record<string, any>> | 表尾单元格的自定义属性 | null | 2.1.24 |
| foot-class | ClassType | TableFootPropFn<ClassType> | 表尾单元格的自定义类名 | null | 2.1.24 |
| foot-style | StyleType | TableFootPropFn<StyleType> | 表尾单元格的自定义样式 | null | 2.1.24 |
| head-attrs | Record<string, any> | TableHeadPropFn<Record<string, any>> | 表头单元格的自定义属性 | null | 2.0.1 |
| head-class | ClassType | TableHeadPropFn<ClassType> | 表头单元格的自定义类名 | null | 2.0.1 |
| head-style | StyleType | TableHeadPropFn<StyleType> | 表头单元格的自定义样式 | null | 2.0.1 |
| height | number | 表格的高度,超出这个高度时会变成可滚动状态 | null | - |
| highlight | boolean | 设置表格行是否在鼠标移入时高亮 | false | - |
| icons | TableIcons | 用于设置表格的各种图标 | {} | 2.1.28 |
| key-config | TableKeyConfig | 设置数据解析 data 时的各项键名 | {} | 2.1.6 |
| locale | LocaleConfig['table'] | 设置多语言配置 | null | 2.1.0 |
| min-height | number | 表格的最小高度,不应大于 height | null | 2.3.7 |
| no-cascaded | boolean | 在树形表格中使父子节点能被独立勾选 | false | 2.1.6 |
| no-transition | boolean | 是否禁用表格的过渡效果 | false | 2.2.14 |
| page-size | number | 设置表格每页的数据量,当为 0 时则禁用分页 | 0 | - |
| render-count | number | 设置表格的最大渲染行数,通常用于大量数据渲染,需设置固定行高 | null | - |
| row-attrs | Record<string, any> | TableRowPropFn<Record<string, any>> | 行的自定义属性 | null | 2.0.1 |
| row-class | ClassType | TableRowPropFn<ClassType> | 行的自定义类名 | null | - |
| row-draggable | boolean | 设置表格行是否可以拖拽排序 | false | - |
| row-height | number | 设置表格的行高,未设置时表格行高将会动态计算 | null | - |
| row-indent | string | number | 设置树形表格每一级的缩进距离 | '16px' | 2.1.6 |
| row-style | StyleType | TableRowPropFn<StyleType> | 行的自定义样式 | null | 2.0.1 |
| scroll-class | ScrollClass | 设置表格各滚动组件的自定义类型 | {} | - |
| scroll-delta-y | number | 设置表格纵向每次滚动的距离 | 20 | - |
| side-padding | number | number[] | 设置表格两侧的内边距 | 0 | 2.1.28 |
| single-filter | boolean | 设置后将限制表格只能有一列开启过滤 | false | - |
| single-sorter | boolean | 设置后将限制表格只能有一列开启排序 | false | - |
| stripe | boolean | 设置表格是否应用斑马纹 | false | - |
| summaries | TableSummaryOptions<any, any>[] | 表格总结行的配置,参考下方 TableSummary 属性 | [] | 2.1.24 |
| transparent | boolean | 设置是否为透明表格,该属性优先级低于其他内置样式属性 | false | - |
| use-x-bar | boolean | 设置表格是否使用横向滚动条 | false | 2.1.25 |
| use-y-bar | boolean | 设置表格是否使用纵向滚动条 | false | - |
| virtual | boolean | 是否开启虚拟滚动 | false | - |
| width | number | string | 表格的宽度,在有固定列时使用 | null | - |
Table 事件#
| 名称 | 说明 | 参数 | 始于 |
|---|---|---|---|
| cell-click | 当点击了单元格时触发 | (payload: TableCellPayload) | 2.0.1 |
| cell-contextmenu | 当右击了单元格时触发 | (payload: TableCellPayload) | 2.0.1 |
| cell-dblclick | 当双击了单元格时触发 | (payload: TableCellPayload) | 2.0.1 |
| cell-enter | 当鼠标移入了单元格时触发 | (payload: TableCellPayload) | 2.0.1 |
| cell-leave | 当鼠标移出了单元格时触发 | (payload: TableCellPayload) | 2.0.1 |
| col-resize-end | 当列结束调整宽度时触发 | (payload: TableColResizePayload) | 2.1.23 |
| col-resize-move | 当列正在调整宽度时触发 | (payload: TableColResizePayload) | 2.1.23 |
| col-resize-start | 当列要开始调整宽度时触发 | (payload: TableColResizePayload) | 2.1.23 |
| foot-click | 当点击了尾部单元格时触发 | (payload: TableFootPayload) | 2.1.24 |
| foot-contextmenu | 当右击了尾部单元格时触发 | (payload: TableFootPayload) | 2.1.24 |
| foot-dblclick | 当双击了尾部单元格时触发 | (payload: TableFootPayload) | 2.1.24 |
| foot-enter | 当鼠标移入了尾部单元格时触发 | (payload: TableFootPayload) | 2.1.24 |
| foot-leave | 当鼠标移出了尾部单元格时触发 | (payload: TableFootPayload) | 2.1.24 |
| head-click | 当点击了头部单元格时触发 | (payload: TableHeadPayload) | 2.0.1 |
| head-contextmenu | 当右击了头部单元格时触发 | (payload: TableHeadPayload) | 2.0.1 |
| head-dblclick | 当双击了头部单元格时触发 | (payload: TableHeadPayload) | 2.0.1 |
| head-enter | 当鼠标移入了头部单元格时触发 | (payload: TableHeadPayload) | 2.0.1 |
| head-leave | 当鼠标移出了头部单元格时触发 | (payload: TableHeadPayload) | 2.0.1 |
| row-check | 当勾选了行复选框时触发 | (payload: TableRowPayload) | - |
| row-check-all | 当进行了全选时触发 | (checked: boolean, partial: boolean) | - |
| row-click | 当点击了行时触发 | (payload: TableRowPayload) | - |
| row-contextmenu | 当右击了行时触发 | (payload: TableRowPayload) | 2.0.1 |
| row-dblclick | 当双击了行时触发 | (payload: TableRowPayload) | 2.0.1 |
| row-drag-end | 当行结束拖拽时触发 | (data: Record<string, unknown>, allData: Record<string, unknown>[], event: DragEvent) | - |
| row-drag-over | 当行正在拖拽时触发 | (data: Record<string, unknown>, event: DragEvent) | - |
| row-drag-start | 当行将要开始拖拽时触发 | (data: Record<string, unknown>, event: DragEvent) | - |
| row-drop | 当行被其他的拖拽行放入时触发 | (data: Record<string, unknown>, dropType?: 'before' | 'after', event: DragEvent) | - |
| row-enter | 当鼠标移入了行时触发 | (payload: TableRowPayload) | - |
| row-expand | 当行拓展内容的展开状态改变时触发 | (payload: TableRowPayload) | - |
| row-filter | 当发生表格数据过滤时触发 | (profiles: TableFilterProfile[], filteredRow: Data[]) | - |
| row-leave | 当鼠标移出了行时触发 | (payload: TableRowPayload) | - |
| row-sort | 当发生表格数据排序时触发 | (profiles: SortProfile[], sortedRow: Data[]) | - |
| row-tree-expand | 当行的树展开状态改变时触发 | (payload: TableRowPayload) | 2.3.1 |
| scroll | 当表格滚动时触发 | (scroll: { type: 'horizontal' | 'vertical', client: number, percent: number }) | 2.1.25 |
| update:data | 当行结束拖拽并且数据结构发生变化时触发 | (data: Data[]) | 2.2.18 |
Table 插槽#
| 名称 | 说明 | 参数 | 始于 |
|---|---|---|---|
| default | 用于定义 TableColumn 和 TableSummary 组件 | - | - |
| empty | 空数据提示内容的插槽 | { isFixed: boolean } | - |
| icon-[name] | 表格图标的插槽,其中 [name] 的可选值请参考 TableIconName | - | 2.1.28 |
Table 方法#
| 名称 | 说明 | 签名 | 始于 |
|---|---|---|---|
| clearFilter | 清除当前表格激活的所有过滤 | () => void | - |
| clearSelected | 清除所有被勾选的行数据 | () => void | - |
| clearSort | 清除表格当前激活的所有排序 | () => void | - |
| getData | 获取表格的数据,通常用于获取拖拽后的数据 | () => Data[] | 2.2.6 |
| getSelected | 获取所有被勾选的行数据 | () => Data[] | - |
| refresh | 刷新表格,将会触发表格的重新布局及数据渲染 | () => Promise<void> | - |
| refreshData | 刷新表格数据,会触发表格重新解析数据 | (data?: any[]) => Promise<void> | 2.2.14 |
| selectRow | 手动勾选或取消勾选行数据 | (keyOrData: Key | Record<any, any>, checked?: boolean): void | 2.3.1 |
| treeExpandRow | 手动展开或收起行数据 | (keyOrData: Key | Record<any, any>, checked?: boolean): void | 2.3.1 |
TableColumn 属性#
| 名称 | 类型 | 说明 | 默认值 | 始于 |
|---|---|---|---|---|
'small' | 'default' | 'large' | 当 type 为 'selection' 时设置复选框大小 | 'default' | - | |
| accessor | (data: any, rowIndex: number) => any | 该列的数据读取方法 | null | - |
| attrs | Record<string, any> | 该列单元格的自定义属性 | null | 2.0.1 |
| cell-span | ColumnCellSpanFn<any> | 设置单元格跨度的回调函数 | null | 2.1.24 |
| class | ClassType | 该列单元格的自定义类名 | null | 2.1.19 |
| disable-row | (data: Data) => boolean | 设置禁用行的回调函数 | null | - |
| ellipsis | boolean | 是否为单元格内容使用省略组件 | false | 2.2.12 |
| filter | TableFilterOptions<any, any> | 列的过滤配置器 | null | - |
| filter-renderer | FilterRenderFn | 自定义过滤器渲染函数 | null | 2.1.18 |
| fixed | boolean | 'left' | 'right' | 是否为固定列,可选值为 left、right,设置为 true 时固定在左侧 | false | - |
| formatter | (value: any) => unknown | 设置单元格内容的格式化方法 | null | 2.2.13 |
| head-renderer | HeadRenderFn | 自定义头部渲染函数 | null | - |
| head-span | number | 设置头部跨度 | 1 | 2.1.24 |
| indented | boolean | 指定为树形表格的缩进列 | false | 2.2.6 |
| key | id-key | string | number | 列的唯一索引,使用模版列时请使用 id-key 代替 | null | - |
| max-width | number | 设置列的最大宽度,通常用于设置了百分比列宽或者列可缩放 | null | 2.3.31 |
| meta | any | 设置列的元数据 | null | 2.1.24 |
| min-width | number | 设置列的最小宽度,通常用于设置了百分比列宽或者列可缩放 | 10 | 2.3.31 |
| name | string | 列的名称 | '' | - |
| no-summary | boolean | 是否禁用自动计算列值的总结数据 | false | 2.1.24 |
| order | number | 列的渲染顺序 | 0 | - |
| order-label | (index: number) => string | number | 当 type 为 'order' 时设置索引显示内容的回调函数 | null | - |
| renderer | ColumnRenderFn | 自定义渲染函数,若 type 为 'expand' 时则为 ExpandRenderFn | null | - |
| selection-size | 'small' | 'default' | 'large' | 当 type 为 'selection' 时设置选择框大小 | 'default' | 2.3.25 |
| single-select | boolean | 当 type 为 'selection' 时设置是否为单选 | false | 2.3.25 |
| sorter | boolean | TableSorterOptions<any> | 列的排序排序器 | null | - |
| style | StyleType | 该列单元格的自定义样式 | null | 2.0.1 |
| summary-renderer | ColumnSummaryRenderFn | 自定义尾部渲染函数 | null | 2.1.24 |
| text-align | TableTextAlign | 设置列的横向对其方式 | 'left' | 2.1.19 |
| truth-index | boolean | 当 type 为 'order' 时设置是否使用行真实(全局)索引 | false | - |
| type | TableColumnType | 设置内置特定类型列 | null | - |
| width | number | `${number}%` | 设置列宽,仅支持数字或百分比 | null | - |
TableColumn 插槽#
| 名称 | 说明 | 参数 | 始于 |
|---|---|---|---|
| default | 列内容的插槽 | Parameters<ColumnRenderFn> | - |
| filter | 列过滤器的插槽 | Parameters<FilterRenderFn> | 2.1.18 |
| head | 列头内容的插槽 | Parameters<HeadRenderFn> | - |
| summary | 列尾内容的插槽 | Parameters<ColumnSummaryRenderFn> | 2.1.24 |
TableColumnGroup 属性#
Since v2.2.12
| 名称 | 类型 | 说明 | 默认值 | 始于 |
|---|---|---|---|---|
| ellipsis | boolean | 是否为表头单元格内容使用省略组件 | false | - |
| fixed | boolean | 'left' | 'right' | 是否为固定列分组,可选值为 left、right,设置为 true 时固定在左侧 | false | - |
| name | string | 列分组的名称 | '' | - |
| order | number | 列分组的渲染顺序,与列的 order 属性共同作用,每一层级、每个分组之间的排序均是独立的 | 0 | - |
| renderer | () => any | 自定义头部渲染函数 | null | - |
| text-align | TableTextAlign | 设置表头单元格的横向对其方式 | 'center' | - |
TableColumnGroup 插槽#
Since v2.2.12
| 名称 | 说明 | 参数 | 始于 |
|---|---|---|---|
| default | 用于定义 TableColumn 组件 | - | - |
| head | 列头内容的插槽 | - | - |
TableSummary 属性#
Since v2.1.24
| 名称 | 类型 | 说明 | 默认值 | 始于 |
|---|---|---|---|---|
| above | boolean | 设置总结行是否在表格上部 | false | - |
| attrs | Record<string, any> | 该行单元格的自定义属性 | null | - |
| cell-span | SummaryCellSpanFn | 设置单元格跨度的回调函数 | null | - |
| class | ClassType | 该行单元格的自定义类名 | null | - |
| key | id-key | string | number | 总结行的唯一索引,使用模版列时请使用 id-key 代替 | null | - |
| meta | any | 设置总结行的元数据 | null | - |
| name | string | 总结行的名称 | '' | - |
| order | number | 总结行的渲染顺序 | 0 | - |
| renderer | SummaryRenderFn | 自定义渲染函数 | null | - |
| style | StyleType | 该行单元格的自定义样式 | null | - |
TableSummary 插槽#
Since v2.1.24
| 名称 | 说明 | 参数 | 始于 |
|---|---|---|---|
| default | 总结行内容的插槽 | Parameters<SummaryRenderFn> | - |
TableSorter 属性#
| 名称 | 类型 | 说明 | 默认值 | 始于 |
|---|---|---|---|---|
| able | boolean | 设置是否可以排序 | false | - |
| method | (prev: any, next: any) => number | 自定义排序的方法,分别接收前后行数据 | null | - |
| order | number | 在多列排序时用于规定各列的先后顺序 | 0 | - |
| type | 'asc' | 'desc' | 排序的类型 | null | - |
TableFilter 属性#
| 名称 | 类型 | 说明 | 默认值 | 始于 |
|---|---|---|---|---|
| able | boolean | 设置是否可以过滤 | false | - |
| active | any | 当前过滤的依赖值,会传入过滤方法 | null | - |
| custom | boolean | 是否为自定义过滤,配合 TableColumn 的 filter 插槽使用 | false | 2.1.18 |
| meta | any | 自定义元数据 | undefined | 2.1.18 |
| method | (active: any | any[], data: any) => boolean | 过滤的方法,接收过滤的依赖值和行数据 | null | - |
| multiple | boolean | 是否开启多条件过滤 | false | - |
| options | (string | { value: any, label?: string, active?: boolean })[] | 过滤的选项,元素为 { label, value } 的对象 | [] | - |