Skip to content

表格 Table

以规则的表格显示数据集。

Attributes

属性描述类型推荐值默认
dataSource数据数组Array-[]
columns表格列Array-[]
hoverablehover 效果boolean-false
align对齐方式stringleft / center / rightleft
empty-text数据数组为空时显示的文本string-暂无数据
TableProps
ts
interface TableProps<T = TableDefaultRow> {
  dataSource: T[]
  columns: TableColumn<T>[]
  hoverable?: boolean
  align?: TableAlign
  emptyText?: string
}
interface TableProps<T = TableDefaultRow> {
  dataSource: T[]
  columns: TableColumn<T>[]
  hoverable?: boolean
  align?: TableAlign
  emptyText?: string
}
ts
interface TableColumn<T = TableDefaultRow> {
  /** render columns item */
  title: string | TableTitleRender
  /** 列数据在数据源中对应的路径 */
  dataIndex?: string
  /** render sourceData item */
  render?: TableDataRender<T>
  /** 列的宽度 */
  width?: string | number
}
interface TableColumn<T = TableDefaultRow> {
  /** render columns item */
  title: string | TableTitleRender
  /** 列数据在数据源中对应的路径 */
  dataIndex?: string
  /** render sourceData item */
  render?: TableDataRender<T>
  /** 列的宽度 */
  width?: string | number
}
TableTitleRender
ts
type TableTitleRender = (
  h: TableRenderH,
  index: number
) => VNode
type TableTitleRender = (
  h: TableRenderH,
  index: number
) => VNode
TableDataRender
ts
type TableDataRender<T = TableDefaultRow> = (
  h: TableRenderH,
  dataItem: T,
  index: number
) => VNode
type TableDataRender<T = TableDefaultRow> = (
  h: TableRenderH,
  dataItem: T,
  index: number
) => VNode
TableRenderH
ts
/**
 * @see h() https://cn.vuejs.org/api/render-function.html
 */
type Children = string | number | boolean | VNode | null | Children[]

type TableRenderH = (
  type: string | Component,
  props?: object | null,
  children?: Children | Slot | Slots | Record<string, () => unknown>
) => VNode
/**
 * @see h() https://cn.vuejs.org/api/render-function.html
 */
type Children = string | number | boolean | VNode | null | Children[]

type TableRenderH = (
  type: string | Component,
  props?: object | null,
  children?: Children | Slot | Slots | Record<string, () => unknown>
) => VNode

Released under the MIT License.