@tanstack/vue-table 适配器是核心表格逻辑的包装器。它的大部分工作与以 “vue” 方式管理状态、提供类型以及单元格/表头/表脚模板的渲染实现有关。
@tanstack/vue-table 重新导出 @tanstack/table-core 的所有 API 以及以下内容:
接受一个 options 对象并返回一个表格。
import { useVueTable } from '@tanstack/vue-table'
const table = useVueTable(options)
// ...渲染你的表格
import { useVueTable } from '@tanstack/vue-table'
const table = useVueTable(options)
// ...渲染你的表格
一个 Vue 组件,用于渲染具有动态值的单元格/表头/表脚模板。
示例:
import { FlexRender } from '@tanstack/vue-table'
<template>
<tbody>
<tr v-for="row in table.getRowModel().rows" :key="row.id">
<td v-for="cell in row.getVisibleCells()" :key="cell.id">
<FlexRender
:render="cell.column.columnDef.cell"
:props="cell.getContext()"
/>
</td>
</tr>
</tbody>
</template>
import { FlexRender } from '@tanstack/vue-table'
<template>
<tbody>
<tr v-for="row in table.getRowModel().rows" :key="row.id">
<td v-for="cell in row.getVisibleCells()" :key="cell.id">
<FlexRender
:render="cell.column.columnDef.cell"
:props="cell.getContext()"
/>
</td>
</tr>
</tbody>
</template>