外观
Table 表格
以原生表格结构展示记录。宽表格可以在组件的外层容器中横向滚动。
import { STable } from '@icecreamqaq/shadcn/table'使用示例
常用 API
| 成员 | 类型 | 用法 |
|---|---|---|
STable.data / columns | Row[] / TableColumnOptions<Row>[] | 也可用 STableColumn 的 prop、label 和作用域插槽声明列。 |
STable.sort / defaultSort | TableSort | null | 可排序列通过 v-model:sort 绑定排序,内部排序保留原数组。 |
STableHead / STableCell | th / td | 在 STableRow 中分别渲染表头和数据单元格。 |
STableCaption.default | slot | 填写表格说明,默认显示在表格下方。 |
STableEmpty.colspan | number | 空状态行的跨度,默认值为 1。可设为当前显示的列数。 |
完整 API
Table12 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
data | readonly Row[] |
columns | readonly TableColumnOptions<Row>[] |
rowKey | Extract<keyof Row, string> | ((row: Row) => PropertyKey) |
sort | TableSort | null |
defaultSort | TableSort | null |
empty | RenderContent |
事件
| 名称 | 类型 |
|---|---|
update:sort | ((sort: TableSort | null) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | (() => VNodeChild) |
cell | ((scope: TableCellScope<Row>) => VNodeChild) |
header | ((scope: TableHeaderScope<Row>) => VNodeChild) |
empty | (() => VNodeChild) |
TableBody2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
TableCaption2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
TableCell2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
TableColumn10 个成员
属性
| 名称 | 类型 |
|---|---|
prop | Extract<keyof Row, string> |
label | string |
children | readonly TableColumnOptions<Row>[] |
sortable | boolean |
accessor | ((row: Row) => unknown) |
renderCell | RenderContent<TableCellScope<Row>> |
renderHeader | RenderContent<TableHeaderScope<Row>> |
插槽
| 名称 | 类型 |
|---|---|
default | ((scope: TableCellScope<Row>) => any) |
header | ((scope: TableHeaderScope<Row>) => any) |
columns | (() => any) |
TableEmpty3 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
colspan | number |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
TableFooter2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
TableHead2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
TableHeader2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
TableRow2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
分组导出
模板标签为 <s-table>。
组件 STable、STableBody、STableCaption、STableCell、STableColumn、STableEmpty、STableFooter、STableHead、STableHeader、STableRow
类型 TableCellScope、TableColumnOptions、TableDataProps、TableHeaderScope、TableSort