# Table
展示数据。
# Usage
# 基础用法
支持仅通过配置渲染表格。
Copy
# 配置列渲染组件
支持直接指定表格列渲染组件。
Copy
# 自定义列内容
支持使用插槽自定义列。
使用 label 和 content 插槽
使用 header 和 body 插槽
Copy
# 使用默认工具栏
通过toolbar
属性开启工具栏,设置toolbarConfig
属性可配置工具栏按钮。
Copy
# 自定义工具栏
支持完全自定义整个工具栏。
Copy
# 使用默认分页器
通过设置pagination
属性开启分页器。
Copy
# 配置默认分页器
开启默认分页器后,设置paginationConfig
属性可配置分页器。
Copy
# 自定义分页器
支持自定义分页器。
Copy
# API
# Attributes
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
data | 表格数据 | Array | - | [] |
columns | 表格列配置 | Array<Column> | - | [] |
toolbar | 是否显示工具栏 | Boolean | - | false |
toolbarConfig | 工具栏配置 | Array<Tool> | - | [] |
pagination | 是否显示分页器 | Boolean | - | false |
paginationConfig | 分页器配置 | Object<Pagination> | - | {...} |
其他属性 | 表格其他属性,请参考element-ui | Any | - | - |
表格分页器默认配置
{
align: "center",
background: true,
layout: "total, sizes, prev, pager, next, jumper",
pageSizes: [10, 20, 30, 50],
currentPage: 1,
pageSize: 10,
pagerCount: 7,
total: null
}
total
实际取值为data.length
# Column 对象结构
属性 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
type | 表格列类型 | String | selection ,index ,expand | - |
prop | 表格列属性 | String | - | - |
label | 表格列标签 | String | - | - |
width | 表格列宽度 | String | - | - |
minWidth | 表格列最小宽度 | String | - | - |
align | 表格列对齐方式 | String | - | - |
fixed | 表格列固定方式 | String | - | - |
showOverflowTooltip | 表格列是否显示tooltip | String | - | - |
className | 表格列样式类名 | String | - | - |
contentComponent | 列内容组件 | Object | - | - |
contentComponentProps | 列内容组件的props | Object | - | - |
contentComponentEvents | 列内容组件的events | Object | - | - |
dataInProps | 内容组件所需数据的prop 名称 | String | - | data |
其他属性 | 表格列其他属性,请参考element-ui 文档 | Any | - | - |
# Tool 对象结构
属性 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
name | 工具名称,工具的标识 | String | - | - |
label | 工具标签名称 | String | - | - |
useTip | 是否使用提示 | Boolean | - | - |
tooltip | 提示内容,默认为工具标签 | String | - | - |
position | 工具位置 | String | left ,right | - |
component | 工具组件 | String | - | el-button |
props | 工具组件配置 | Object | - | - |
events | 工具绑定的事件 | Object | - | - |
# Pagination 对象结构
属性 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
align | 对齐方式 | String | left ,center ,right | center |
background | 使用背景色 | Boolean | - | true |
layout | 组件布局 | String | - | total,sizes,prev,pager,next,jumper |
pageSizes | 每页条数选项 | Array | - | [10, 20, 30, 50] |
currentPage | 当前页码 | Number | - | 1 |
pageSize | 每页条数 | Number | - | 20 |
pagerCount | 页码按钮 | Number | - | 7 |
total | 总条数 | Number | - | - |
# Events
事件名 | 说明 | 参数 |
---|---|---|
el-table 事件 | el-table 原本的事件,请参考element-ui 文档 | - |
tool-${tool.name} | 当工具栏的工具使用默认的el-button 时,点击按钮会触发该事件 | - |
pagination | 分页跳转、分页大小改变事件 | {currentPage, pageSize, from} |
pagination 事件参数详细说明:
pagination
事件的参数是一个对象,其中 currentPage 为当前页码,pageSize 为每页显示条数,from 为触发该事件来源,值为currentPage
或pageSize
。
# Methods
方法名 | 说明 | 参数 |
---|---|---|
tableFunction | el-table 原本提供的方法,请参考element-ui 文档 | - |
# Slots
名称 | 说明 | 参数 |
---|---|---|
toolbar | 工具栏完全自定义内容 | - |
header | 表头自定义内容 | {column, $index } |
body | 表格主体自定义内容 | {row, column, $index} |
${column.prop}Label | 表格列表头自定义内容 | {column, $index} |
${column.prop}Content | 表格列内容自定义内容 | {row, column, $index} |
default | 表格默认插槽 | - |
append | 插入至表格最后一行之后的内容 | - |
pagination | 分页器完全自定义内容 | - |