Vue

作者 onmax008232b5d7a5无许可证719 个星标收录于 2026年10月8日更新于 2026年10月8日仓库2天前更新

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.

AI 生成的概览

指导使用组合式 API、script setup 宏、响应式系统和内置组件编写 Vue 3 组件。

功能
该技能为编写 Vue 3 单文件组件提供参考指导,涵盖 script setup 宏(如 defineProps、defineEmits、defineModel)、响应式系统(ref、shallowRef、computed、侦听器)以及内置组件(Transition、Teleport、Suspense、KeepAlive)。它给出偏好建议,例如使用 TypeScript、script setup 搭配 lang ts,以及优先使用组合式 API 而非选项式 API,并附有组件模板和常用导入清单。它产出的是编码指导,而非文件或脚本。
适用场景
适用于编写或审查 Vue 单文件组件、定义 props、emits 或 model、处理侦听器与生命周期钩子,或使用内置组件与指令的场景。面向 Vue 3.5 及更高版本并使用组合式 API。
运行要求
不需要脚本或工具,仅为说明与参考文档。其指导假定使用 Vue 3 项目和 TypeScript。

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 shallowRef over ref if deep reactivity is not needed
  • Always use Composition API over Options API
  • Discourage using Reactive Props Destructure

Core

TopicDescriptionReference
Script Setup & Macros<script setup>, defineProps, defineEmits, defineModel, defineExpose, defineOptions, defineSlots, genericsscript-setup-macros [blocked]
Reactivity & Lifecycleref, shallowRef, computed, watch, watchEffect, effectScope, lifecycle hooks, composablescore-new-apis [blocked]

Features

TopicDescriptionReference
Built-in Components & DirectivesTransition, Teleport, Suspense, KeepAlive, v-memo, custom directivesadvanced-patterns [blocked]

Quick Reference

Component Template

vue
<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

ts
// Reactivityimport { ref, shallowRef, computed, reactive, readonly, toRef, toRefs, toValue } from 'vue'
// Watchersimport { watch, watchEffect, watchPostEffect, onWatcherCleanup } from 'vue'
// Lifecycleimport { onMounted, onUpdated, onUnmounted, onBeforeMount, onBeforeUpdate, onBeforeUnmount } from 'vue'
// Utilitiesimport { nextTick, defineComponent, defineAsyncComponent } from 'vue'

来源与署名

来源:onmax/nuxt-skills位于skills/vue提交008232b

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架