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

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 trang web xây dựng bằng Alpine.js, dùng thư viện TanStack Table. Skill dành cho lập trình viên web muốn có một bảng không giao diện (headless) để tự tạo kiểu.

Khi nào nên dùng

  • ✓Khi bạn đang xây dựng một trang Alpine.js cần một bảng có cấu trúc gồm các bản ghi.
  • ✓Khi dữ liệu bảng của bạn thay đổi theo thời gian và bảng phải cập nhật trên màn hình.
  • ✓Khi bạn muốn hiển thị tiêu đề và ô của bảng bằng hàm trợ giúp FlexRender.

Liên kết skill

https://github.com/TanStack/table/blob/main/packages/alpine-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/alpine-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 Alpine.js có danh sách khách hàng trong bảng. Tôi cài đặt điều đó với TanStack Table như thế nào?”

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

Cách hoạt động

Skill đưa ra các mẫu mã để tạo bảng từ định nghĩa cột và dữ liệu, rồi chỉ cách hiển thị tiêu đề và hàng trên trang bằng vòng lặp template của Alpine.

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.

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

Setup

import Alpine from 'alpinejs'
import {
  FlexRender,
  createTable,
  tableFeatures,
  type ColumnDef,
} from '@tanstack/alpine-table'

type Person = { id: string; name: string }
const features = tableFeatures({})
const columns: Array<ColumnDef<typeof features, Person>> = [
  { accessorKey: 'name', header: 'Name' },
]

Alpine.data('peopleTable', () => {
  const local = Alpine.reactive({
    data: [{ id: '1', name: 'Ada' }] as Array<Person>,
  })
  const table = createTable({
    features,
    columns,
    get data() {
      return local.data
    },
    getRowId: (row) => row.id,
  })

  return { table, FlexRender }
})

window.Alpine = Alpine
Alpine.start()

Render real table structure with x-for; use x-html="FlexRender({ header })" or x-html="FlexRender({ cell })" only for renderer output.

Construction and rendering

Wrap changing data in Alpine.reactive and expose it with get data(). The adapter tracks option getters; data: local.data captures a snapshot and does not follow later array replacements. Keep static columns and features outside getters.

The returned table is a reactive proxy. Read Table APIs directly in x-text, x-for, x-if, or bound attributes; no Subscribe component is needed.

Build table structure and interactive controls as real Alpine markup. Use x-html="FlexRender({ header })" or x-html="FlexRender({ cell })" for renderer output. Alpine does not initialize directives inside x-html strings; use templates or Alpine.bind bundles for buttons and inputs.

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/alpine-table/dist/index.d.ts, createTable.d.ts, and reactivity.d.ts. Core feature APIs are in node_modules/@tanstack/table-core/dist/features/.

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

Tôi có cần biết TanStack Table từ trước không?

Không cần sâu. Skill chỉ đến hướng dẫn cốt lõi để có nền tảng, rồi bao quát phần thiết lập riêng cho Alpine.

Làm sao để giữ bảng đồng bộ với dữ liệu thay đổi?

Skill khuyên bọc dữ liệu trong store phản ứng của Alpine và cung cấp nó qua một getter.

Đây có chỉ dành cho Alpine.js không?

Đúng. Skill bao quát phiên bản Alpine của Table v9, và các framework khác có hướng dẫn riêng.

Chi tiết

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

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

repo: TanStack/table

Độ phổ biến

Sao GitHub
29k
Vị trí xếp hạng
#9805
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ự