
Vue
SkillVue 3.5 的参考:<script setup> 与 defineProps、defineEmits、defineModel 等宏,响应式 API、侦听器与生命周期,Transition、Teleport、Suspense、KeepAlive 等内置组件。要求 agent 一律用组合式 API 与 TypeScript 的 <script setup>,不需要深层响应时优先 shallowRef。由 Anthony Fu 从官方文档生成。
name: vue
description: Vue 3 Composition API, script setup macros, reactivity system, and built-in components. Use when writing Vue SFCs, defineProps/defineEmits/defineModel, watchers, or using Transition/Teleport/Suspense/KeepAlive.
metadata:
author: Anthony Fu
version: "2026.9.25"
source: Generated from https://github.com/vuejs/docs, scripts at https://github.com/antfu/skills
Vue
Based on Vue 3.5, generated at 2026-09-25. Always use Composition API with
<script setup lang="ts">.
Preferences
- Prefer TypeScript over JavaScript
- Prefer
<script setup lang="ts">over<script> - For performance, prefer
shallowRefoverrefif deep reactivity is not needed - Always use Composition API over Options API
- Discourage using Reactive Props Destructure
Core
| Topic | Description | Reference |
|---|---|---|
| Script Setup & Macros | <script setup>, defineProps, defineEmits, defineModel, defineExpose, defineOptions, defineSlots, generics | script-setup-macros |
| Reactivity & Lifecycle | ref, shallowRef, computed, watch, watchEffect, effectScope, lifecycle hooks, composables | core-new-apis |
Features
| Topic | Description | Reference |
|---|---|---|
| Built-in Components & Directives | Transition, Teleport, Suspense, KeepAlive, v-memo, custom directives | advanced-patterns |
Quick Reference
Component Template
<script setup lang="ts">
import { ref, computed, watch, onMounted } from 'vue'
const props = defineProps<{
title: string
count?: number
}>()
const emit = defineEmits<{
update: [value: string]
}>()
const model = defineModel<string>()
const doubled = computed(() => (props.count ?? 0) * 2)
watch(() => props.title, (newVal) => {
console.log('Title changed:', newVal)
})
onMounted(() => {
console.log('Component mounted')
})
</script>
<template>
<div>{{ title }} - {{ doubled }}</div>
</template>
Key Imports
// Reactivity
import { ref, shallowRef, computed, reactive, readonly, toRef, toRefs, toValue } from 'vue'
// Watchers
import { watch, watchEffect, watchPostEffect, onWatcherCleanup } from 'vue'
// Lifecycle
import { onMounted, onUpdated, onUnmounted, onBeforeMount, onBeforeUpdate, onBeforeUnmount } from 'vue'
// Utilities
import { nextTick, defineComponent, defineAsyncComponent } from 'vue'
相關資源

Nuxt
SkillNuxt 5 全栈 Vue 框架的参考:目录结构、配置、文件路由、useFetch 等数据获取、自动导入、服务端路由、渲染模式、SSR 与水合注意事项、模块与 Layers,重点说明 Nuxt 5 改用 Nitro v3 与 Vite 8 带来的变化。由 Anthony Fu 从官方文档生成。
antfu/skills6.1k
Pinia
SkillPinia v4 状态管理的参考:定义 store 的 state、getters 与 actions,插件、在 store 中使用组合式函数、store 之间的组合,测试、SSR、Nuxt 集成与 HMR;建议优先用 Setup Store、解构时用 storeToRefs。由 Anthony Fu 从官方文档生成。
antfu/skills6.1k
Vue Best Practices
SkillVue 开发的默认工作流:以 Vue 3、Composition API 和 script setup 加 TypeScript 为标准,编码前先读响应式、单文件组件、数据流与组合式函数等核心参考并规划组件拆分,插槽、过渡动画、性能优化等专题按需加载,最后逐项自检。
vuejs-ai/skills3.4k
Create Adaptable Composable
Skill指导 agent 编写库级别的 Vue 组合式函数,让参数既能传普通值,也能传 ref 或 getter:按只读或可写选用 MaybeRefOrGetter 或 MaybeRef,并在 watch 等响应式副作用里用 toValue()、toRef() 统一取值。需要 Vue 3 或 Nuxt 3 以上。
vuejs-ai/skills3.4k
Vue Options API Best Practices
Skill面向使用 Options API(data()、methods、this)的 Vue 3 项目:说明如何借助 defineComponent 获得 TypeScript 类型推断,为 props、事件处理器和 computed 加类型,以及 methods 与生命周期钩子里不要用箭头函数、防抖函数不要在实例间共享状态等常见坑。
vuejs-ai/skills3.4k
Antfu Conventions
SkillAnthony Fu 对 JavaScript / TypeScript 项目的约定与工具偏好:代码组织、显式导入、Vitest 测试写法,以及 @antfu/ni、开启 antislop 的 @antfu/eslint-config、Knip、tsdown 和统一的 ci 脚本,新建项目时参照 antfu/starter-ts 模板。
antfu/skills6.1k