Vue 3 组合式函数最佳实践 (Composables)

Provides reusable Vue 3 composables for table pagination and async request logic.

840|261|Updated Apr 18, 2019
One-click install
npx skills add https://github.com/TencentBlueKing/bk-bcs --skill vue-3-composables
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Vue 3 组合式函数最佳实践 (Composables)
Source: https://github.com/TencentBlueKing/bk-bcs/tree/main/bcs-services/bcs-project-manager/.cursor/skills/vue-composables
Command: npx skills add https://github.com/TencentBlueKing/bk-bcs --skill vue-3-composables

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) components.

What problem does it solve?

Frontend pages repeatedly reimplement pagination, loading states, and data fetching logic, leading to duplicated code and inconsistent behavior across list views.

Core Features & Use Cases

  • useTable Composable: Encapsulates pagination, loading state, and data fetching for list pages in a single hook.
  • bk-table Integration: Works directly with bk-table components via remote pagination and page-change event handlers.
  • Use Case: When building a host list page, call useTable with your data-fetching function and bind the returned loading, data, and pagination values to bk-table instead of writing pagination logic by hand.

Quick Start

Ask the AI to build a Vue 3 list page using the useTable composable with bk-table remote pagination for your data API.

Frequently Asked Questions about Vue 3 组合式函数最佳实践 (Composables)

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement table pagination in Vue 3 with composables?

Use the useTable composable by passing your data-fetching function, then bind the returned data, pagination, and loading values to your table component. Handle page changes with the provided handlePageChange and handleLimitChange functions.

How to use useTable with bk-table remote pagination?

Bind the pagination object and data from useTable to bk-table, enable the remote-pagination attribute, and wire page-change and page-limit-change events to the composable's handlers. Add v-bkloading with the loading state for visual feedback.

Does useTable work with any data fetching function?

Yes, useTable accepts any asynchronous request function such as getHostList as its parameter. The composable manages calling it with the correct pagination parameters and tracking the loading state.

When should I use composables instead of writing pagination logic inline?

Use composables whenever multiple pages share list, pagination, or async request patterns. Inline logic is acceptable only for one-off pages, but duplicated pagination code across pages should be extracted into hooks like useTable.