vue

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Vue

Vue

The skill is based on Vue 3.5+, generated at 2026-01-28.
Vue is a progressive JavaScript framework for building user interfaces. It builds on standard HTML, CSS, and JavaScript with intuitive API and world-class documentation. The Composition API with
<script setup>
and TypeScript is the recommended approach for building Vue applications.
本技能基于Vue 3.5+版本生成,生成时间为2026年1月28日。
Vue是一款用于构建用户界面的渐进式JavaScript框架。它基于标准HTML、CSS和JavaScript构建,拥有直观的API和世界级的文档。结合
<script setup>
的Composition API与TypeScript是构建Vue应用的推荐方案。

Core References

核心参考

TopicDescriptionReference
Reactivity Systemref, reactive, computed, watch, and watchEffectcore-reactivity
主题描述参考
响应式系统ref、reactive、computed、watch和watchEffectcore-reactivity

Components

组件

TopicDescriptionReference
PropsDeclare and validate component props with TypeScriptcomponents-props
Events (Emits)Emit custom events from componentscomponents-emits
SlotsPass template content to child componentscomponents-slots
v-modelTwo-way binding on custom componentscomponents-v-model
Lifecycle HooksRun code at specific component lifecycle stagescomponents-lifecycle
主题描述参考
Props使用TypeScript声明并验证组件Propscomponents-props
自定义事件(Emits)从组件中触发自定义事件components-emits
插槽(Slots)向子组件传递模板内容components-slots
v-model自定义组件上的双向绑定components-v-model
生命周期钩子在组件生命周期的特定阶段执行代码components-lifecycle

Features

功能特性

Script Setup & TypeScript

Script Setup & TypeScript

TopicDescriptionReference
Script SetupComposition API syntactic sugar for SFCsfeatures-script-setup
TypeScriptType-safe Vue components with Composition APIfeatures-typescript
主题描述参考
Script Setup单文件组件(SFC)的Composition API语法糖features-script-setup
TypeScript结合Composition API实现类型安全的Vue组件features-typescript

Reusability

可复用性

TopicDescriptionReference
ComposablesEncapsulate and reuse stateful logicfeatures-composables
Custom DirectivesLow-level DOM manipulation directivesfeatures-directives
Template RefsDirect DOM and component instance accessfeatures-template-refs
主题描述参考
组合式函数(Composables)封装并复用有状态逻辑features-composables
自定义指令底层DOM操作指令features-directives
模板引用(Template Refs)直接访问DOM和组件实例features-template-refs

Advanced

进阶内容

TopicDescriptionReference
Provide/InjectDependency injection across component treeadvanced-provide-inject
Async & SuspenseTop-level await pitfalls, async components, Suspenseadvanced-async-suspense
主题描述参考
Provide/Inject跨组件树的依赖注入advanced-provide-inject
异步与Suspense顶层await陷阱、异步组件、Suspenseadvanced-async-suspense

Key Recommendations

关键建议

  • Use
    <script setup lang="ts">
    for all components
  • Prefer
    ref()
    over
    reactive()
    for declaring state
  • Use type-based prop declarations with interfaces
  • Use
    defineModel()
    for v-model (3.4+)
  • Destructure props reactively (3.5+) for cleaner code
  • Extract composables for reusable stateful logic
  • 所有组件均使用
    <script setup lang="ts">
  • **优先使用
    ref()
    而非
    reactive()
    **声明状态
  • 使用基于类型的Props声明(结合接口)
  • **使用
    defineModel()
    **实现v-model(3.4+版本)
  • 响应式解构Props(3.5+版本)以简化代码
  • 提取组合式函数用于复用有状态逻辑