Table 表格
基础用法(数组配置)
使用TableArrayColumns定义表单
使用TableObjectColumns定义表单
基础用法(对象配置)
插槽
只需要配置slot就可以使用插槽
多级表头
通过children来配置按钮
列的props
通过props可以配置el-table-column的props
列的按钮
如果列中想要显示按钮但是又不想用插槽,可以使用buttons来配置按钮
列的显示与隐藏
可以使用show来控制列的显示与隐藏
操作列
可以使用actionprop在末尾添加“操作”列,列的标题默认为“操作”;action可以在[TableColums]抽离在另一个文件时使用
WARNING
推荐使用插槽
Table Attributes
TIP
除了下面的Attributes,您还可以传入el-table的原生props和事件,例如show-header、selection-change等,更多Attributes请看el-table文档
| 名称 | 说明 | 类型 | 默认值 |
|---|---|---|---|
data | 表格数据 | array | [] |
options | 表格配置项 | TableColums | |
hiddenColsByLabel | 根据标题隐藏列 | array | [] |
action | 操作列 | object: {label?: String} & Omit<TableColumn, "children" | "slot"> | [] |
TableColums
TableColums由TableArrayColumns和TableObjectColumns,都是由 TableColum 组成,其中TableObjectColumns对象上的value可以是字符串
| 名称 | 说明 | 类型 | 是否必须 | 默认值 |
|---|---|---|---|---|
label | 列的标题,优先级比props的label低 | string | 否 | |
prop | 列内容的字段名,优先级比props的prop低 | string | 否 | |
props | el-table-column的props | object | 否 | |
children | 子级列 | array:Array<TableColumn> | 否 | |
buttons | 列内容的字段名,优先级比props的prop低 | ButtonOption | 否 | |
show | 是否显示列 | show?: boolean | (() => boolean) | 否 | true |
slot | 插槽名称 | string | 否 |
ButtonOption
| 名称 | 说明 | 类型 | 是否必须 | 默认值 |
|---|---|---|---|---|
label | 按钮的文字 | string | 否 | |
props | el-button的props | ((scope: {row: any, column: any, $index:number}) => Partial<ButtonProps>) | Partial<ButtonProps> | 否 | |
click | 点击按钮的事件 | Function | 否 |