vue-skilld by harlan-zw/vue-ecosystem-skills
npx skills add https://github.com/harlan-zw/vue-ecosystem-skills --skill vue-skilldvue用于构建现代 Web 用户界面的渐进式 JavaScript 框架。
版本: 3.6.0-beta.8 依赖: @vue/shared@3.6.0-beta.8, @vue/compiler-dom@3.6.0-beta.8, @vue/runtime-vapor@3.6.0-beta.8, @vue/compiler-sfc@3.6.0-beta.8, @vue/runtime-dom@3.6.0-beta.8, @vue/server-renderer@3.6.0-beta.8 标签: csp: 1.0.28-csp, legacy: 2.7.16, v2-latest: 2.7.16, rc: 3.5.0-rc.1, alpha: 3.6.0-alpha.7, beta: 3.6.0-beta.8, latest: 3.5.30
参考: 文档 — API 参考、指南 • GitHub Issues — 错误、变通方案、边界情况 • GitHub Discussions — 问答、模式、最佳实践 • 发布日志 — 变更日志、破坏性变更、新 API
本节记录特定版本的 API 变更 — 请优先关注近期的主要/次要版本发布。
新增: createVaporApp() (实验性) — v3.6 新增,创建一个 Vapor 模式的应用实例,无需引入虚拟 DOM 运行时;使用 createApp() 创建标准的 VDOM 应用
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
新增: vaporInteropPlugin (实验性) — v3.6 新增,安装到 VDOM createApp() 实例中,以允许在 VDOM 树中使用 Vapor 组件;没有它,Vapor 单文件组件无法在 VDOM 应用中使用 来源
新增: <script setup vapor> 属性 (实验性) — v3.6 新增,将单文件组件选择加入 Vapor 模式编译;仅适用于 <script setup>;不支持选项式 API、app.config.globalProperties 或 getCurrentInstance() 来源
新增: useTemplateRef(key) — v3.5 新增,是匹配 ref="key" 属性的普通 ref 变量的首选替代方案;与旧的仅支持静态模式不同,支持运行时的动态字符串 ID 来源
新增: useId() — v3.5 新增,为每个组件实例生成稳定的唯一 ID,保证 SSR 和客户端注水之间匹配;替代了表单/无障碍属性的手动 ID 管理 来源
新增: onWatcherCleanup(fn) — v3.5 新增,在 watch 或 watchEffect 回调内部注册一个清理回调;替代了 onCleanup 参数模式,并且可以从嵌套函数中调用 来源
新增: hydrateOnVisible()、hydrateOnIdle()、hydrateOnInteraction()、hydrateOnMediaQuery() — v3.5 新增,传递给 defineAsyncComponent({ hydrate: hydrateOnVisible() }) 的惰性注水策略;没有 hydrate 选项,异步组件会立即注水 来源
新增: defineModel() 稳定版 — 从 v3.3 的实验性状态提升为 v3.4 的稳定版;自动声明一个 prop 并返回一个可变 ref;替代了手动的 defineProps + defineEmits('update:modelValue') 模式 来源
新增: defineProps 带默认值的解构 — v3.5 稳定化 (v3.3 时是实验性);const { count = 0 } = defineProps<{ count?: number }>() 替代了 withDefaults(defineProps<...>(), { count: 0 });解构后的变量必须包装在 getter 中才能传递给 watch() 或组合式函数 来源
破坏性变更: @vnodeXXX 事件监听器 — v3.4 移除,现在是一个编译器错误;请改用 @vue:XXX 监听器 (例如 @vue:mounted) 来源
破坏性变更: 响应性语法糖 ($ref、$computed 等) — v3.3 弃用后于 v3.4 移除;曾是实验性功能,与现已稳定的 props 解构功能不同;使用 Vue Macros 插件可继续使用 来源
破坏性变更: 全局 JSX 命名空间 — 自 v3.4 起默认不再注册;在 tsconfig.json 中设置 jsxImportSource: "vue" 或导入 vue/jsx 以恢复;仅影响 TSX 用户 来源
破坏性变更: app.config.unwrapInjectedRef — v3.4 移除;inject() 中的 ref 解包现在始终启用且无法禁用 来源
新增: <Teleport defer> 属性 — v3.5 新增,在当前渲染周期后挂载传送门,以便目标元素可以由 Vue 在同一组件树中渲染;为了向后兼容,需要显式的 defer 属性 来源
其他变更: defineSlots<{}>() 宏 v3.3 新增,用于类型化的插槽声明 · defineOptions({}) 宏 v3.3 新增,用于无需单独的 <script> 块即可设置组件选项 · toRef(() => getter) v3.3 增强,可接受普通值和 getter 函数 · toValue() v3.3 新增,将值/getter/ref 规范化为值 (toRef 的逆操作) · v-bind 同名简写 v3.4 新增 (:id 是 :id="id" 的简写) · data-allow-mismatch 属性 v3.5 新增,用于抑制注水不匹配警告 · useHost() / useShadowRoot() v3.5 新增,用于自定义元素宿主访问 · v-is 指令 v3.4 移除 (请改用 is="vue:ComponentName") · 响应式系统在 v3.6 中进行了 alien-signals 重构,改善了内存使用,无 API 变更
使用响应式 props 解构 (3.5+) 配合原生默认值语法,而非 withDefaults() — 解构后的变量是响应式的,编译器会自动重写对 props.x 的访问。当传递给组合式函数或 watch 时,请包装在 getter 中:watch(() => count, ...) 来源
在组合式函数中使用 toValue() 来规范化 MaybeRefOrGetter<T> 参数 — 统一处理普通值、ref 和 getter 函数,因此调用者可以传递任何形式,而组合式函数无需关心 来源
使用 onWatcherCleanup() (3.5+) 替代 watch 和 watchEffect 中的 onCleanup 回调参数 — 它可以从同步执行栈中的任何辅助函数调用,而不仅仅是顶层回调,使得清理逻辑更容易提取 来源
使用 useTemplateRef() (3.5+) 替代具有匹配变量名的普通 ref 来获取模板引用 — 支持动态 ref ID,并通过 @vue/language-tools 2.1 提供更好的 IDE 自动补全和类型检查 来源
在 SSR 应用中使用 useId() (3.5+) 为表单元素和无障碍属性生成 ID — 生成的 ID 在服务器和客户端渲染之间保持稳定,防止注水不匹配。避免在 computed() 内部调用,因为这可能导致实例冲突 来源
对大型不可变数据结构使用 shallowRef() / shallowReactive() — 深度响应式通过代理陷阱跟踪每个属性访问;浅层变体避免了这种开销,同时仍对根 .value 的替换做出响应 来源
直接传递计算值作为 active props,而不是用于比较的 ID — 当任何接收到的 prop 发生变化时,子组件都会重新渲染,因此传递一个稳定的布尔值可以避免在只有一个列表项的活动状态发生变化时重新渲染每个列表项 来源
当计算属性每次求值都返回一个新对象时,接受 oldValue 并在数据等价时原样返回它 — 避免不必要的下游副作用触发,因为 Vue 3.4+ 仅在计算值的引用发生变化时才触发副作用 来源
在 SSR 中使用带有惰性注水策略 (3.5+) 的 defineAsyncComponent — hydrateOnVisible()、hydrateOnIdle()、hydrateOnInteraction() 和 hydrateOnMediaQuery() 是可摇树优化的,并将注水推迟到组件实际需要时
import { defineAsyncComponent, hydrateOnVisible } from 'vue'
const AsyncComp = defineAsyncComponent({ loader: () => import('./Comp.vue'), hydrate: hydrateOnVisible() })
<script setup vapor> 按组件选择加入 Vapor 模式 — Vapor 完全避免了虚拟 DOM 差异比较,并达到与 Solid/Svelte 5 基准测试相当的性能,但不支持选项式 API、app.config.globalProperties 或 getCurrentInstance()。使用 vaporInteropPlugin 在现有应用中混合使用 Vapor 和 VDOM 组件 来源每周安装量
120
代码仓库
GitHub 星标数
145
首次出现
2026年2月18日
安全审计
安装于
github-copilot81
codex79
opencode76
gemini-cli75
claude-code74
amp73
vueThe progressive JavaScript framework for building modern web UI.
Version: 3.6.0-beta.8 Deps: @vue/shared@3.6.0-beta.8, @vue/compiler-dom@3.6.0-beta.8, @vue/runtime-vapor@3.6.0-beta.8, @vue/compiler-sfc@3.6.0-beta.8, @vue/runtime-dom@3.6.0-beta.8, @vue/server-renderer@3.6.0-beta.8 Tags: csp: 1.0.28-csp, legacy: 2.7.16, v2-latest: 2.7.16, rc: 3.5.0-rc.1, alpha: 3.6.0-alpha.7, beta: 3.6.0-beta.8, latest: 3.5.30
References: Docs — API reference, guides • GitHub Issues — bugs, workarounds, edge cases • GitHub Discussions — Q&A, patterns, recipes • Releases — changelog, breaking changes, new APIs
This section documents version-specific API changes — prioritize recent major/minor releases.
NEW: createVaporApp() (experimental) — new in v3.6, creates a Vapor-mode app instance without pulling in the Virtual DOM runtime; use createApp() for standard VDOM apps source
NEW: vaporInteropPlugin (experimental) — new in v3.6, install into a VDOM createApp() instance to allow Vapor components inside VDOM trees; without it, Vapor SFCs cannot be used in VDOM apps source
NEW: <script setup vapor> attribute (experimental) — new in v3.6, opts an SFC into Vapor Mode compilation; only works with <script setup>; does not support Options API, app.config.globalProperties, or getCurrentInstance() source
NEW: useTemplateRef(key) — new in v3.5, preferred replacement for plain ref variable names matching ref="key" attributes; supports dynamic string IDs at runtime unlike the old static-only pattern source
NEW: useId() — new in v3.5, generates stable unique IDs per component instance guaranteed to match between SSR and client hydration; replaces manual ID management for form/accessibility attributes source
NEW: onWatcherCleanup(fn) — new in v3.5, registers a cleanup callback inside a watch or watchEffect callback; replaces the onCleanup parameter pattern and can be called from nested functions source
NEW: hydrateOnVisible(), hydrateOnIdle(), hydrateOnInteraction(), hydrateOnMediaQuery() — new in v3.5, lazy hydration strategies passed to defineAsyncComponent({ hydrate: hydrateOnVisible() }); without the hydrate option, async components hydrate immediately source
NEW: defineModel() stable — promoted from experimental in v3.3 to stable in v3.4; automatically declares a prop and returns a mutable ref; replaces the manual defineProps + defineEmits('update:modelValue') pattern source
NEW: defineProps destructure with defaults — stabilized in v3.5 (was experimental in v3.3); const { count = 0 } = defineProps<{ count?: number }>() replaces withDefaults(defineProps<...>(), { count: 0 }); destructured vars must be wrapped in getters to pass to watch() or composables source
BREAKING: @vnodeXXX event listeners — removed in v3.4, are now a compiler error; use @vue:XXX listeners instead (e.g. @vue:mounted) source
BREAKING: Reactivity Transform ($ref, $computed, etc.) — removed in v3.4 after being deprecated in v3.3; was experimental and distinct from the now-stable props destructure feature; use Vue Macros plugin to continue using it source
BREAKING: Global JSX namespace — no longer registered by default since v3.4; set jsxImportSource: "vue" in tsconfig.json or import vue/jsx to restore it; affects TSX users only source
BREAKING: app.config.unwrapInjectedRef — removed in v3.4; ref unwrapping in inject() is now always enabled and cannot be disabled source
NEW: <Teleport defer> prop — new in v3.5, mounts the teleport after the current render cycle so the target element can be rendered by Vue in the same component tree; requires explicit defer attribute for backwards compatibility source
Also changed: defineSlots<{}>() macro NEW v3.3 for typed slot declarations · defineOptions({}) macro NEW v3.3 to set component options without a separate <script> block · toRef(() => getter) enhanced in v3.3 to accept plain values and getters · toValue() NEW v3.3 normalizes values/getters/refs to values (inverse of toRef) · v-bind same-name shorthand NEW v3.4 (:id shorthand for :id="id") · data-allow-mismatch attribute NEW v3.5 to suppress hydration mismatch warnings · / NEW v3.5 for custom element host access · directive REMOVED v3.4 (use instead) · reactivity system alien-signals refactor in v3.6 improves memory usage with no API changes
Use reactive props destructure (3.5+) with native default value syntax instead of withDefaults() — destructured variables are reactive and the compiler rewrites accesses to props.x automatically. When passing to composables or watch, wrap in a getter: watch(() => count, ...) source
Use toValue() in composables to normalize MaybeRefOrGetter<T> arguments — handles plain values, refs, and getter functions uniformly so callers can pass any form without the composable caring source
Use onWatcherCleanup() (3.5+) instead of the callback parameter in and — it can be called from any helper function in the sync execution stack, not just the top-level callback, making cleanup logic easier to extract
<script setup vapor> when targeting performance-sensitive UI — Vapor avoids Virtual DOM diffing entirely and achieves Solid/Svelte 5 benchmark parity, but does not support Options API, app.config.globalProperties, or getCurrentInstance(). Use vaporInteropPlugin to mix Vapor and VDOM components in an existing app sourceWeekly Installs
120
Repository
GitHub Stars
145
First Seen
Feb 18, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
github-copilot81
codex79
opencode76
gemini-cli75
claude-code74
amp73
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
115,300 周安装
useHost()useShadowRoot()v-isis="vue:ComponentName"onCleanupwatchwatchEffectUse useTemplateRef() (3.5+) instead of a plain ref with a matching variable name for template refs — supports dynamic ref IDs and provides better IDE auto-completion and type checking via @vue/language-tools 2.1 source
Use useId() (3.5+) for form element and accessibility IDs in SSR apps — generated IDs are stable across server and client renders, preventing hydration mismatches. Avoid calling inside computed() as it can cause instance conflicts source
Use shallowRef() / shallowReactive() for large immutable data structures — deep reactivity tracks every property access via proxy traps; shallow variants avoid this overhead while still reacting to root .value replacement source
Pass computed values directly as active props rather than IDs for comparison — child components re-render when any received prop changes, so passing a stable boolean avoids re-rendering every list item when only one item's active state changes source
When a computed returns a new object on every evaluation, accept oldValue and return it unchanged when data is equivalent — avoids unnecessary downstream effect triggers since Vue 3.4+ only triggers effects when the computed value reference changes source
Use defineAsyncComponent with a lazy hydration strategy (3.5+) for SSR — hydrateOnVisible(), hydrateOnIdle(), hydrateOnInteraction(), and hydrateOnMediaQuery() are tree-shakable and defer hydration until the component is actually needed
import { defineAsyncComponent, hydrateOnVisible } from 'vue'
const AsyncComp = defineAsyncComponent({ loader: () => import('./Comp.vue'), hydrate: hydrateOnVisible() })