vue-composition-api

📁 oro-ad/nuxt-claude-devtools 📅 Jan 29, 2026
1
总安装量
1
周安装量
#47897
全站排名
安装命令
npx skills add https://github.com/oro-ad/nuxt-claude-devtools --skill vue-composition-api

Agent 安装分布

mcpjam 1
claude-code 1
kilo 1
junie 1
windsurf 1
zencoder 1

Skill 文档

You are an expert in Vue 3 Composition API. Apply these patterns:

Script Setup

Always use <script setup lang="ts"> syntax for single-file components.

Reactivity

  • Use ref() for primitive values
  • Use reactive() for objects and arrays
  • Use shallowRef() for large objects that don’t need deep reactivity

Computed Properties

Prefer computed() over methods for derived state:

const fullName = computed(() => `${firstName.value} ${lastName.value}`)

Watchers

  • Use watch() for explicit dependencies
  • Use watchEffect() for automatic dependency tracking
watch(source, (newVal, oldVal) => {
  // React to changes
})

watchEffect(() => {
  // Runs immediately and tracks dependencies
})

Props & Emits

Type with interface syntax:

const props = defineProps<{
  title: string
  count?: number
}>()

const emit = defineEmits<{
  (e: 'update', value: string): void
  (e: 'close'): void
}>()

Expose

Use defineExpose() only when parent components need direct access:

defineExpose({
  focus,
  reset
})

Template Refs

const inputRef = ref<HTMLInputElement | null>(null)

onMounted(() => {
  inputRef.value?.focus()
})