Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)29k · #9831

getting-started

Skill này làm gì

Skill này chỉ cách tạo và hiển thị một bảng dữ liệu trong ứng dụng Svelte bằng TanStack Table. Skill dành cho lập trình viên Svelte dùng Svelte 5 và muốn có một bảng có thể tùy biến kiểu dáng tự do.

Khi nào nên dùng

  • ✓Khi bạn đang xây dựng một component Svelte hiển thị bản ghi trong bảng.
  • ✓Khi dữ liệu bảng Svelte của bạn được giữ trong runes và phải cập nhật trên màn hình.
  • ✓Khi bạn muốn thêm tính năng truy vấn hoặc virtual cho bảng Svelte.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/TanStack/table/blob/main/packages/svelte-table/skills/getting-started/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tôi đang xây dựng một trang Svelte 5 liệt kê người dùng trong bảng. Làm sao để thiết lập?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill đưa ra một component định nghĩa các cột, tạo bảng bằng createTable và lặp qua các tiêu đề, dòng và ô trong template.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Svelte Table setup and integration

Before starting, run intent load @tanstack/table-core#core for the shared headless model and stable-input rules.

Setup

Keep features and columns outside reactive work; expose changing rune values through getters.

<script lang="ts">
  import {
    createTable,
    FlexRender,
    tableFeatures,
  } from '@tanstack/svelte-table'

  type Person = { firstName: string; age: number }
  const features = tableFeatures({})
  const columns = [
    { accessorKey: 'firstName', header: 'First name' },
    { accessorKey: 'age', header: 'Age' },
  ]
  let data = $state<Person[]>([{ firstName: 'Ada', age: 36 }])

  const table = createTable({
    features,
    columns,
    get data() {
      return data
    },
  })
</script>

<table>
  <thead>
    {#each table.getHeaderGroups() as group (group.id)}
      <tr
        >{#each group.headers as header (header.id)}<th
            >{#if !header.isPlaceholder}<FlexRender {header} />{/if}</th
          >{/each}</tr
      >
    {/each}
  </thead>
  <tbody>
    {#each table.getRowModel().rows as row (row.id)}
      <tr
        >{#each row.getAllCells() as cell (cell.id)}<td
            ><FlexRender {cell} /></td
          >{/each}</tr
      >
    {/each}
  </tbody>
</table>

Essential constraints

V9 requires Svelte 5 and createTable. Expose changing runes through getters; data captured once cannot follow reassignment. Keep features and columns outside reactive work and use $derived for transformed arrays.

Table owns models and state. The application owns markup, CSS, interactions, and accessibility. Core-only tables use row.getAllCells(); visibility-aware methods need columnVisibilityFeature. Optional state and APIs require their features. Put row-model slots after their prerequisite features in tableFeatures().

Load by task

  • For repeated features, defaults, typed contexts, or component registries, read reusable app hooks.
  • For Query-backed data, server pages, sorting, filtering, or request keys, read TanStack Query integration.
  • For virtual rows, columns, dynamic measurement, or infinite scrolling, read TanStack Virtual integration.
  • For controlled state, tracked reads, or render subscriptions, read table state.
  • For feature registration, missing feature APIs, or processing ownership, run intent load @tanstack/table-core#table-features and read only references needed by the task.
  • For v8 code, read the migration checklist.

API discovery

Inspect node_modules/@tanstack/svelte-table/dist/index.d.ts, then the exported adapter declarations for the installed version. Inspect optional core APIs under node_modules/@tanstack/table-core/dist/features/.

Câu hỏi thường gặp

Cần phiên bản Svelte nào?

Skill nói Table v9 yêu cầu Svelte 5.

Dữ liệu thay đổi được truyền tới bảng như thế nào?

Skill khuyên đưa giá trị rune ra qua một getter, để bảng luôn đọc giá trị hiện tại.

Điều gì vẽ các ô trong bảng?

Component FlexRender vẽ các tiêu đề và ô.

Chi tiết

Mô tả gốc của tác giả

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

repo: TanStack/table

Độ phổ biến

Sao GitHub
29k
Vị trí xếp hạng
#9831
Giấy phép
MIT
Cập nhật
21/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự