跳到正文
Skillpedia
网站与界面(前端)29k · #9817

getting-started

它能做什么

这项技能展示如何在 Octane 应用中用 TanStack Table 构建数据表格。适合使用 Octane 及其 TSRX 模板语法的开发者。

适用场景

  • ✓当你在构建一个用表格显示记录列表的 Octane 页面的时候。
  • ✓当你需要通过其渲染辅助函数显示表头和单元格的时候。
  • ✓当你想在 TSRX 文件中用列辅助函数定义表格列的时候。

技能链接

https://github.com/TanStack/table/blob/main/packages/octane-table/skills/getting-started/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/TanStack/table/blob/main/packages/octane-table/skills/getting-started/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我正在做一个 Octane 页面,用表格显示产品列表。应该如何设置?”

每周 5 个新技能,1 分钟读完。

工作原理

它提供一个带有列和数据的示例组件,然后在标记中循环遍历表头、行和单元格,将它们显示在页面上。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Load intent load @tanstack/table-core#core first for the headless model, stable inputs, and column inference.

Setup

import { createRoot, useState } from 'octane'
import {
  createColumnHelper,
  tableFeatures,
  useTable,
} from '@tanstack/octane-table'

type Person = { name: string }
const features = tableFeatures({})
const helper = createColumnHelper<typeof features, Person>()
const columns = helper.columns([helper.accessor('name', { header: 'Name' })])

function PeopleTable() @{
  const [data] = useState<Person[]>([{ name: 'Ada' }])
  const table = useTable({ features, columns, data })

  <table>
    <thead>
      @for (const group of table.getHeaderGroups(); key group.id) {
        <tr>
          @for (const header of group.headers; key header.id) {
            <th><table.FlexRender header={header} /></th>
          }
        </tr>
      }
    </thead>
    <tbody>
      @for (const row of table.getRowModel().rows; key row.id) {
        <tr>
          @for (const cell of row.getAllCells(); key cell.id) {
            <td><table.FlexRender cell={cell} /></td>
          }
        </tr>
      }
    </tbody>
  </table>
}

const rootElement = document.getElementById('root')
if (!rootElement) throw new Error('Root element not found')
createRoot(rootElement).render(PeopleTable)

Construction and rendering

This adapter distributes authored TypeScript and TSRX. Configure the consumer with octane() in vite.config.ts and the TSRX JSX import source octane. Author component bodies with @{ ... } and keyed @for loops for rows, headers, and cells.

Import from @tanstack/octane-table. Render table.FlexRender as a component so it gets its own Octane scope. It preserves numbers including 0, render descriptors, and component functions.

Keep features and column definitions at module scope. For inputs that depend on component state, use useMemo; pass the current stable data array to useTable. Convert non-renderable values with String(value) when displaying them as text.

Read for the task

  • When adding or configuring optional features, load intent load @tanstack/table-core#table-features and read only references for the requested behavior.
  • For state ownership or reactive reads, read table-state.
  • When tables share features, defaults, or reusable UI, read create-table-hook.

API discovery

Inspect node_modules/@tanstack/octane-table/src/index.d.ts, the matching *.tsrx.d.ts sidecar, and src/types.ts. This package publishes authored source; core APIs are in installed @tanstack/table-core/dist/.

常见问题

什么是 TSRX?

示例是用 TSRX 编写的,这是该适配器使用的组件语法,因此看起来与普通 JSX 不同。

表格的数据从哪里来?

示例使用 useState 把数据保存在 Octane 状态中,并将其传给表格。

这会取代核心表格指南吗?

不会,它假设你已经先阅读过核心指南中关于无头表格模型的内容。

详情

作者的原始描述

Create and render Table v9 with the octane adapter. Route reusable createTableHook components, and framework setup; use table-state for reactive ownership.

repo: TanStack/table

热度

GitHub 星标
29k
排名
#9817
许可证
MIT
更新时间
2026/10/21

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能