Table表格·续8
| customRender | 生成复杂数据的渲染函数,参数分别为当前行的值,当前行数据,行索引,@return 里面可以设置表格行/列合并,可参考 demo 表格行/列合并 | Function({text, record, index}) {}|v-slot | - | |
|---|---|---|---|---|
| sorter | 排序函数,本地排序使用一个函数(参考 Array.sort 的 compareFunction),需要服务端排序可设为 true | Function|boolean | - | |
|---|---|---|---|---|
| sortOrder | 排序的受控属性,外界可用此控制列的排序,可设置为 ‘ascend’ ‘descend’ false | boolean|string | - | |
|---|---|---|---|---|
| sortDirections |
支持的排序方式,取值为 ‘ascend’ ‘descend’ |
Array |
[‘ascend’, ‘descend’] |
1.5.0 |
|
|
|
|
|
| title | 列头显示文字 | string|slot | - | |
|---|---|---|---|---|
| width | 列宽度 | string|number | - | |
|---|---|---|---|---|
| customCell |
设置单元格属性 |
Function(record, rowIndex) |
- |
|
|
|
|
|
|
| customHeaderCell |
设置头部单元格属性 |
Function(column) |
- |
|
|
|
|
|
|
| onFilter |
本地模式下,确定筛选的运行函数, 使用 template 或 jsx 时作为filter事件使用 |
Function |
- |
|
|
|
|
|
|
| onFilterDropdownVisibleChange |
自定义筛选菜单可见变化时调用,使用 template 或 jsx 时作为filterDropdownVisibleChange事件使用 |
function(visible) {} |
- |
|
|
|
|
|
|
| slots |
使用 columns 时,可以通过该属性配置支持 slot 的属性,如 slots: { filterIcon: ‘XXX’} |
object |
- |
|
|
|
|
|
|
ColumnGroup
| title | 列头显示文字 | string|slot | - |
|---|---|---|---|
| slots |
使用 columns 时,可以通过该属性配置支持 slot 的属性,如 slots: { title: ‘XXX’} |
object |
- |
|
|
|
|
分页的配置项。
| position | 指定分页显示的位置 | ‘top’ | ‘bottom’ | ‘both’ | ‘bottom’ |
|---|---|---|---|
更多配置项,请查看 Pagination。
rowSelection
选择功能的配置。
| columnWidth | 自定义列表选择框宽度 | string|number | - |
|---|---|---|---|
| columnTitle | 自定义列表选择框标题 | string|VNode | - |
|---|---|---|---|
| fixed |
把选择框列固定在左边 |
boolean |
- |
|
|
|
|
| getCheckboxProps |
选择框的默认属性配置 |
Function(record) |
- |
|
|
|
|
| hideDefaultSelections |
去掉『全选』『反选』两个默认选项 |
boolean |
false |
|
|
|
|
| selectedRowKeys |
指定选中项的 key 数组,需要和 onChange 进行配合 |
string[] |
[] |
|
|
|
|
| selections | 自定义选择配置项, 设为 true 时使用默认选择项 | object[]|boolean | true |
|---|---|---|---|
| type |
多选/单选,checkbox or radio |
string |
checkbox |
|
|
|
|
| onChange |
选中项发生变化时的回调 |
Function(selectedRowKeys, selectedRows) |
- |
|
|
|
|
| onSelect |
用户手动选择/取消选择某列的回调 |
Function(record, selected, selectedRows, nativeEvent) |
- |
|
|
|
|
| onSelectAll |
用户手动选择/取消选择所有列的回调 |
Function(selected, selectedRows, changeRows) |
- |
|
|
|
|
| onSelectInvert |
用户手动选择反选的回调 |
Function(selectedRows) |
- |
|
|
|
|
| x | 设置横向滚动,也可用于指定滚动区域的宽和高,可以设置为像素值,百分比,true 和 ‘max-content’ | number | true | - | |
|---|---|---|---|---|
| y | 设置纵向滚动,也可用于指定滚动区域的宽和高,可以设置为像素值,百分比,true 和 ‘max-content’ | number | true | - | |
|---|---|---|---|---|
| scrollToFirstRowOnChange |
当分页、排序、筛选变化后是否滚动到表格顶部 |
boolean |
- |
1.5.0 |
|
|
|
|
|
selection
自定义选择配置项
| key |
Vue 需要的 key,建议设置 |
string |
- |
|
|
|
|
| text | 选择项显示的文字 | string|VNode | - |
|---|---|---|---|
| onSelect |
选择项点击回调 |
Function(changeableRowKeys) |
- |
|
|
|
|
注意
在 Table 中,dataSource 和 columns 里的数据值都需要指定 key 值。对于 dataSource 默认将每列数据的 key 属性作为唯一的标识。
如果你的数据没有这个属性,务必使用 rowKey 来指定数据列的主键。若没有指定,控制台会出现缺少 key 的提示,表格组件也会出现各类奇怪的错误。
// 比如你的数据主键是 uidreturn <Table rowKey="uid" />;// 或return <Table rowKey={record => record.uid} />;