AGENT SKILL
vuejs-composition-api
Write Vue 3 components with the Composition API, script setup, and composables
- License 许可
- Apache-2.0
- 所属仓库
- linktogo/maggie
- 最近更新
- 2026-11-14
- Stars
- ★ 2
- Forks
- 2
01 前言 Front Matter
- name
- vuejs-composition-api
- globs
- [ "**/*.vue", "**/*.ts" ]
- description
- Write Vue 3 components with the Composition API, script setup, and composables
03 SKILL.md 正文
Vue Composition API
Use <script setup> with the Composition API for new components. It gives better
type inference and makes logic reuse explicit.
Rules
- Reach for
reffor primitives andreactivefor objects; be consistent within a component. Rememberrefvalues need.valuein script (but not in the template). - Derive from state with
computed, not by writing back into another ref inside a watcher. Computeds are cached and declarative. - Use
watch/watchEffectfor side effects (fetching on an id change, syncing to storage) — not to compute values thatcomputedshould own. - Extract reusable stateful logic into composables named
useXthat return refs and functions. They compose other composables and hold no template. - Define props and emits with
defineProps/defineEmits(typed). Treat props as read-only — emit an event to request a change rather than mutating a prop.
Anti-patterns
- Mutating a prop directly.
- A
watchthat sets a ref which anotherwatchreacts to — collapse it into acomputed. - Destructuring a
reactiveobject, which loses reactivity — usetoRefsif you must destructure.
04 同仓库更多 Skills
vuejs-state-management
Manage Vue application state with Pinia and the right state locality
★ 2
reactjs-hooks
Use React hooks correctly — dependencies, effects, and custom hooks
★ 2
reactjs-component-design
Write small, composable React components with clean props and no needless state
★ 2
postgres-query-performance
Diagnose and fix slow PostgreSQL queries with indexes and EXPLAIN
★ 2
postgres-migrations
Write safe, reversible, zero-downtime PostgreSQL schema migrations
★ 2
nx-task-running
Run Nx tasks efficiently with affected, caching, and target dependencies
★ 2