vue-skilld
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesevuejs/core vue
vueVue.js核心 vue
vueVersion: 3.6.0-beta.6 (Feb 2026)
Deps: @vue/shared@3.6.0-beta.6, @vue/runtime-dom@3.6.0-beta.6, @vue/runtime-vapor@3.6.0-beta.6, @vue/compiler-dom@3.6.0-beta.6, @vue/compiler-sfc@3.6.0-beta.6, @vue/server-renderer@3.6.0-beta.6
Tags: csp: 1.0.28-csp (Sep 2016), legacy: 2.7.16 (Dec 2023), v2-latest: 2.7.16 (Dec 2023), rc: 3.5.0-rc.1 (Aug 2024), alpha: 3.6.0-alpha.7 (Dec 2025), beta: 3.6.0-beta.6 (Feb 2026), latest: 3.5.28 (Feb 2026)
References: Docs — API reference, guides • GitHub Issues — bugs, workarounds, edge cases • GitHub Discussions — Q&A, patterns, recipes • Releases — changelog, breaking changes, new APIs
版本: 3.6.0-beta.6(2026年2月)
依赖: @vue/shared@3.6.0-beta.6, @vue/runtime-dom@3.6.0-beta.6, @vue/runtime-vapor@3.6.0-beta.6, @vue/compiler-dom@3.6.0-beta.6, @vue/compiler-sfc@3.6.0-beta.6, @vue/server-renderer@3.6.0-beta.6
标签: csp: 1.0.28-csp(2016年9月), legacy: 2.7.16(2023年12月), v2-latest: 2.7.16(2023年12月), rc: 3.5.0-rc.1(2024年8月), alpha: 3.6.0-alpha.7(2025年12月), beta: 3.6.0-beta.6(2026年2月), latest: 3.5.28(2026年2月)
参考链接: 文档 — API参考、指南 • GitHub Issues — 问题、解决方案、边缘情况 • GitHub Discussions — 问答、模式、实践方案 • 版本发布记录 — 更新日志、破坏性变更、新API
API Changes
API变更
This section documents version-specific API changes — prioritize recent major/minor releases.
-
NEW:(experimental) — new in v3.6, creates a Vapor-mode app instance without pulling in the Virtual DOM runtime; use
createVaporApp()for standard VDOM apps sourcecreateApp() -
NEW:(experimental) — new in v3.6, install into a VDOM
vaporInteropPlugininstance to allow Vapor components inside VDOM trees; without it, Vapor SFCs cannot be used in VDOM apps sourcecreateApp() -
NEW:attribute (experimental) — new in v3.6, opts an SFC into Vapor Mode compilation; only works with
<script setup vapor>; does not support Options API,<script setup>, orapp.config.globalPropertiessourcegetCurrentInstance() -
NEW:— new in v3.5, preferred replacement for plain
useTemplateRef(key)variable names matchingrefattributes; supports dynamic string IDs at runtime unlike the old static-only pattern sourceref="key" -
NEW:— 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
useId() -
NEW:— new in v3.5, registers a cleanup callback inside a
onWatcherCleanup(fn)orwatchcallback; replaces thewatchEffectparameter pattern and can be called from nested functions sourceonCleanup -
NEW:,
hydrateOnVisible(),hydrateOnIdle(),hydrateOnInteraction()— new in v3.5, lazy hydration strategies passed tohydrateOnMediaQuery(); without thedefineAsyncComponent({ hydrate: hydrateOnVisible() })option, async components hydrate immediately sourcehydrate -
NEW:stable — promoted from experimental in v3.3 to stable in v3.4; automatically declares a prop and returns a mutable ref; replaces the manual
defineModel()+definePropspattern sourcedefineEmits('update:modelValue') -
NEW:destructure with defaults — stabilized in v3.5 (was experimental in v3.3);
definePropsreplacesconst { count = 0 } = defineProps<{ count?: number }>(); destructured vars must be wrapped in getters to pass towithDefaults(defineProps<...>(), { count: 0 })or composables sourcewatch() -
BREAKING:event listeners — removed in v3.4, are now a compiler error; use
@vnodeXXXlisteners instead (e.g.@vue:XXX) source@vue:mounted -
BREAKING: Reactivity Transform (,
$ref, 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$computed -
BREAKING: Globalnamespace — no longer registered by default since v3.4; set
JSXinjsxImportSource: "vue"or importtsconfig.jsonto restore it; affects TSX users only sourcevue/jsx -
BREAKING:— removed in v3.4; ref unwrapping in
app.config.unwrapInjectedRefis now always enabled and cannot be disabled sourceinject() -
NEW: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
<Teleport defer>attribute for backwards compatibility sourcedefer
Also changed: macro NEW v3.3 for typed slot declarations · macro NEW v3.3 to set component options without a separate block · enhanced in v3.3 to accept plain values and getters · NEW v3.3 normalizes values/getters/refs to values (inverse of ) · same-name shorthand NEW v3.4 ( shorthand for ) · 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
defineSlots<{}>()defineOptions({})<script>toRef(() => getter)toValue()toRefv-bind:id:id="id"data-allow-mismatchuseHost()useShadowRoot()v-isis="vue:ComponentName"本节记录特定版本的API变更——优先关注近期的主版本/次版本更新。
-
新增:(实验性)——v3.6版本新增,无需引入Virtual DOM运行时即可创建Vapor模式的应用实例;标准VDOM应用请使用
createVaporApp()来源createApp() -
新增:(实验性)——v3.6版本新增,安装到基于VDOM的
vaporInteropPlugin实例中,允许在VDOM树中使用Vapor组件;如果不安装该插件,Vapor SFC无法在VDOM应用中使用 来源createApp() -
新增:属性(实验性)——v3.6版本新增,将SFC设置为Vapor模式编译;仅适用于
<script setup vapor>;不支持Options API、<script setup>或app.config.globalProperties来源getCurrentInstance() -
新增:——v3.5版本新增,是与
useTemplateRef(key)属性匹配的普通ref="key"变量名的推荐替代方案;与旧的仅静态模式不同,它在运行时支持动态字符串ID 来源ref -
新增:——v3.5版本新增,为每个组件实例生成稳定的唯一ID,确保SSR和客户端水合时ID一致;替代表单/无障碍属性的手动ID管理 来源
useId() -
新增:——v3.5版本新增,在
onWatcherCleanup(fn)或watch回调中注册清理回调;替代watchEffect参数模式,可从嵌套函数中调用 来源onCleanup -
新增:、
hydrateOnVisible()、hydrateOnIdle()、hydrateOnInteraction()——v3.5版本新增,延迟水合策略,可传递给hydrateOnMediaQuery();如果不设置defineAsyncComponent({ hydrate: hydrateOnVisible() })选项,异步组件会立即水合 来源hydrate -
新增:稳定版——从v3.3的实验性特性升级为v3.4的稳定特性;自动声明一个prop并返回一个可变的ref;替代手动的
defineModel()+defineProps模式 来源defineEmits('update:modelValue') -
新增:带默认值的解构——v3.5版本稳定(v3.3为实验性);
defineProps替代const { count = 0 } = defineProps<{ count?: number }>();传递给组合式函数或withDefaults(defineProps<...>(), { count: 0 })时,需用getter包裹:watch来源watch(() => count, ...) -
破坏性变更:事件监听器——v3.4版本移除,现在会触发编译器错误;请改用
@vnodeXXX监听器(例如@vue:XXX) 来源@vue:mounted -
破坏性变更:响应式转换(、
$ref等)——在v3.3版本弃用后,v3.4版本移除;属于实验性特性,与现在稳定的props解构功能不同;如需继续使用,请安装Vue Macros插件 来源$computed -
破坏性变更:全局命名空间——v3.4版本起不再默认注册;可在
JSX中设置tsconfig.json或导入jsxImportSource: "vue"来恢复;仅影响TSX用户 来源vue/jsx -
破坏性变更:——v3.4版本移除;
app.config.unwrapInjectedRef中的ref自动解包现在始终启用,无法禁用 来源inject() -
新增:属性——v3.5版本新增,在当前渲染周期后挂载Teleport,以便目标元素可由Vue在同一组件树中渲染;为了向后兼容,需要显式添加
<Teleport defer>属性 来源defer
其他变更: 宏 v3.3新增,用于类型化插槽声明 · 宏 v3.3新增,无需单独的块即可设置组件选项 · v3.3增强,支持接受普通值和getter · v3.3新增,将值/getter/refs归一化为值(的逆操作) · 同名简写 v3.4新增(是的简写) · 属性 v3.5新增,用于抑制水合不匹配警告 · / v3.5新增,用于自定义元素宿主访问 · 指令 v3.4移除(请改用) · v3.6版本响应式系统alien-signals重构,在不改变API的情况下提升了内存使用效率
defineSlots<{}>defineOptions({})<script>toRef(() => getter)toValue()toRefv-bind:id:id="id"data-allow-mismatchuseHost()useShadowRoot()v-isis="vue:ComponentName"Best Practices
最佳实践
-
Use reactive props destructure (3.5+) with native default value syntax instead of— destructured variables are reactive and the compiler rewrites accesses to
withDefaults()automatically. When passing to composables orprops.x, wrap in a getter:watchsourcewatch(() => count, ...) -
Usein composables to normalize
toValue()arguments — handles plain values, refs, and getter functions uniformly so callers can pass any form without the composable caring sourceMaybeRefOrGetter<T> -
Use(3.5+) instead of the
onWatcherCleanup()callback parameter inonCleanupandwatch— 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 sourcewatchEffect -
Use(3.5+) instead of a plain
useTemplateRef()with a matching variable name for template refs — supports dynamic ref IDs and provides better IDE auto-completion and type checking viaref2.1 source@vue/language-tools -
Use(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
useId()as it can cause instance conflicts sourcecomputed() -
Use/
shallowRef()for large immutable data structures — deep reactivity tracks every property access via proxy traps; shallow variants avoid this overhead while still reacting to rootshallowReactive()replacement source.value -
Pass computed values directly asprops 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
active -
When a computed returns a new object on every evaluation, acceptand 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
oldValue -
Usewith a lazy hydration strategy (3.5+) for SSR —
defineAsyncComponent,hydrateOnVisible(),hydrateOnIdle(), andhydrateOnInteraction()are tree-shakable and defer hydration until the component is actually neededhydrateOnMediaQuery()
ts
import { defineAsyncComponent, hydrateOnVisible } from 'vue'
const AsyncComp = defineAsyncComponent({
loader: () => import('./Comp.vue'),
hydrate: hydrateOnVisible()
})source
- (experimental) Opt in to Vapor Mode per-component with when targeting performance-sensitive UI — Vapor avoids Virtual DOM diffing entirely and achieves Solid/Svelte 5 benchmark parity, but does not support Options API,
<script setup vapor>, orapp.config.globalProperties. UsegetCurrentInstance()to mix Vapor and VDOM components in an existing app sourcevaporInteropPlugin
-
在3.5+版本中,使用带原生默认值语法的响应式props解构替代——解构后的变量是响应式的,编译器会自动将访问重写为
withDefaults()。传递给组合式函数或props.x时,需用getter包裹:watch来源watch(() => count, ...) -
在组合式函数中使用来归一化
toValue()参数——统一处理普通值、refs和getter函数,调用者可以传递任意形式的值,组合式函数无需关心 来源MaybeRefOrGetter<T> -
使用(3.5+)替代
onWatcherCleanup()和watch中的watchEffect回调参数——它可以在同步执行栈中的任何辅助函数中调用,而不仅仅是顶层回调,使清理逻辑更易于提取 来源onCleanup -
使用(3.5+)替代与模板ref匹配的普通
useTemplateRef()变量名——支持动态ref ID,并通过ref2.1提供更好的IDE自动补全和类型检查 来源@vue/language-tools -
在SSR应用中,使用(3.5+)生成表单元素和无障碍属性的ID——生成的ID在服务器和客户端渲染中保持稳定,避免水合不匹配。避免在
useId()中调用,否则可能导致实例冲突 来源computed() -
对于大型不可变数据结构,使用/
shallowRef()——深度响应式会通过代理陷阱跟踪每个属性的访问;浅响应式变体可避免此开销,同时仍会对根shallowReactive()的变更做出响应 来源.value -
直接传递计算值作为props,而非用于比较的ID——子组件在接收到的props变更时会重新渲染,传递稳定的布尔值可避免仅单个项的激活状态变更时,所有列表项都重新渲染 来源
active -
当计算属性每次求值都返回新对象时,接受并在数据等价时返回旧值——Vue 3.4+仅在计算属性值引用变更时触发副作用,这样可避免不必要的下游副作用触发 来源
oldValue -
对于SSR,使用带延迟水合策略的(3.5+)——
defineAsyncComponent、hydrateOnVisible()、hydrateOnIdle()和hydrateOnInteraction()支持摇树优化,会延迟水合直到组件真正需要时才执行hydrateOnMediaQuery()
ts
import { defineAsyncComponent, hydrateOnVisible } from 'vue'
const AsyncComp = defineAsyncComponent({
loader: () => import('./Comp.vue'),
hydrate: hydrateOnVisible()
})来源
- (实验性)针对性能敏感的UI,通过为单个组件启用Vapor模式——Vapor完全避免了Virtual DOM diffing,性能达到Solid/Svelte 5的基准水平,但不支持Options API、
<script setup vapor>或app.config.globalProperties。在现有应用中混合使用Vapor和VDOM组件时,请使用getCurrentInstance()来源vaporInteropPlugin