1
1
# 介绍
2
2
3
3
::: info 提示
4
- 刚接触 Vue.js?先从[ 基础指南] ( /guide/introduction.html ) 开始吧。
4
+ 刚接触 Vue.js?先从[ 基础指南] ( http://cn.vuejs.org /guide/introduction.html) 开始吧。
5
5
:::
6
6
7
7
本指南主要是为有 Vue 2 经验的、希望了解 Vue 3 的新功能和更改的用户而提供的。** 在试用 Vue 3 之前,你不必完整阅读这些内容** 。虽然看起来有很多变化,但很多你已经了解和喜欢 Vue 的部分仍是一样的。不过我们希望尽可能全面,并为每处变化提供详细的例子。
@@ -20,14 +20,13 @@ Generated from
20
20
[](https://vimeo.com/440868720)
21
21
to replace this iframe with an image link to avoid the assets from vimeo being blocked
22
22
<iframe src="https://player.vimeo.com/video/440868720" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>
23
- -->
24
23
<style>
25
24
#video-whatsnew { display: block; width: 640px; height: 360px; }
26
25
#video-whatsnew:hover { outline: 3px #3eaf7c solid; }
27
26
</style>
28
- <a href =" https://vimeo.com/440868720 " id =" video-whatsnew " target =" _blank " rel =" noopener noreferrer " ><img src =" /cn/whatsnew.jpg " alt =" 观看视频 What's new in Vue 3 (英文) " /></a >
29
-
27
+ <a href="https://vimeo.com/440868720" id="video-whatsnew" target="_blank" rel="noopener noreferrer"><img src="/cn/whatsnew.jpg" alt="观看视频 What's new in Vue 3 (英文)" style="display: block; width: 640px; height: 360px;" /></a>
30
28
开始学习 Vue 3 [Vue Mastery](https://www.vuemastery.com/courses-path/vue3)。
29
+ -->
31
30
32
31
## 快速开始
33
32
@@ -52,83 +51,83 @@ to replace this iframe with an image link to avoid the assets from vimeo being b
52
51
53
52
## 用于迁移的构建版本
54
53
55
- 如果你打算要将一个基于 Vue 2 的项目或者库升级到 Vue 3,我们提供了一个与 Vue 2 API 兼容的 Vue 3 构建版本,详情见[ 用于迁移的构建版本] ( ./migration-build.html ) 。
54
+ 如果你打算要将一个基于 Vue 2 的项目或者库升级到 Vue 3,我们提供了一个与 Vue 2 API 兼容的 Vue 3 构建版本,详情见[ 用于迁移的构建版本] ( .. /migration-build.html ) 。
56
55
57
56
## 值得注意的新特性
58
57
59
58
Vue 3 中一些需要关注的新功能包括:
60
59
61
- - [ 组合式 API] ( /guide/composition-api-introduction.html )
62
- - [ Teleport] ( /guide/teleport.html )
63
- - [ 片段] ( /guide/migration /fragments.html)
64
- - [ Emits 组件选项] ( /guide/component-custom-events.html )
60
+ - [ 组合式 API] ( https://cn.vuejs.org /guide/composition-api-introduction.html)
61
+ - [ Teleport] ( https://cn.vuejs.org /guide/teleport.html)
62
+ - [ 片段] ( ../new /fragments.html)
63
+ - [ Emits 组件选项] ( https://cn.vuejs.org /guide/component-custom-events.html)
65
64
- [ 来自 ` @vue/runtime-core ` 的 ` createRenderer ` API] ( https://github.com/vuejs/vue-next/tree/master/packages/runtime-core ) ,用于创建自定义渲染器
66
- - [ 单文件组件组合式 API 语法糖 (` <script setup> ` )] ( /api/sfc-script-setup.html )
67
- - [ 单文件组件状态驱动的 CSS 变量 (` <style> ` 中的 ` v-bind ` )] ( /api/sfc-style.html#状态驱动的动态-css )
65
+ - [ 单文件组件组合式 API 语法糖 (` <script setup> ` )] ( https://cn.vuejs.org /api/sfc-script-setup.html)
66
+ - [ 单文件组件状态驱动的 CSS 变量 (` <style> ` 中的 ` v-bind ` )] ( https://cn.vuejs.org /api/sfc-style.html#状态驱动的动态-css)
68
67
- [ SFC ` <style scoped> ` 现在可以包含全局规则或只针对插槽内容的规则] ( https://github.com/vuejs/rfcs/blob/master/active-rfcs/0023-scoped-styles-changes.md )
69
- - [ Suspense] ( /guide/migration /suspense.html) <Badge text =" 实验性 " type =" warning " />
68
+ - [ Suspense] ( . /suspense.html) <Badge text =" 实验性 " type =" warning " />
70
69
71
70
## 非兼容的变更
72
71
73
72
下面列出了从 2.x 开始的非兼容的变更:
74
73
75
74
### 全局 API
76
75
77
- - [ 全局 Vue API 已更改为使用应用程序实例] ( /guide/migration /global-api.html)
78
- - [ 全局和内部 API 已经被重构为支持 tree-shake] ( /guide/migration /global-api-treeshaking.html)
76
+ - [ 全局 Vue API 已更改为使用应用程序实例] ( . /global-api.html)
77
+ - [ 全局和内部 API 已经被重构为支持 tree-shake] ( . /global-api-treeshaking.html)
79
78
80
79
### 模板指令
81
80
82
- - [ 组件上 ` v-model ` 用法已更改,以替换 ` v-bind.sync ` ] ( /guide/migration /v-model.html)
83
- - [ ` <template v-for> ` 和非 ` v-for ` 节点上的 ` key ` 用法已更改] ( /guide/migration /key-attribute.html)
84
- - [ 在同一元素上使用的 ` v-if ` 和 ` v-for ` 优先级已更改] ( /guide/migration /v-if-v-for.html)
85
- - [ ` v-bind="object" ` 现在排序敏感] ( /guide/migration /v-bind.html)
81
+ - [ 组件上 ` v-model ` 用法已更改,以替换 ` v-bind.sync ` ] ( . /v-model.html)
82
+ - [ ` <template v-for> ` 和非 ` v-for ` 节点上的 ` key ` 用法已更改] ( . /key-attribute.html)
83
+ - [ 在同一元素上使用的 ` v-if ` 和 ` v-for ` 优先级已更改] ( . /v-if-v-for.html)
84
+ - [ ` v-bind="object" ` 现在排序敏感] ( . /v-bind.html)
86
85
- [ ` v-on:event.native ` 修饰符已移除] ( ./v-on-native-modifier-removed.md )
87
- - [ ` v-for ` 中的 ` ref ` 不再注册 ref 数组] ( /guide/migration /array-refs.html)
86
+ - [ ` v-for ` 中的 ` ref ` 不再注册 ref 数组] ( . /array-refs.html)
88
87
89
88
### 组件
90
89
91
- - [ 只能使用普通函数创建函数式组件] ( /guide/migration /functional-components.html)
92
- - [ ` functional ` attribute 在单文件组件 (SFC) 的 ` <template> ` 和 ` functional ` 组件选项中被废弃] ( /guide/migration /functional-components.html)
93
- - [ 异步组件现在需要使用 ` defineAsyncComponent ` 方法来创建] ( /guide/migration /async-components.html)
90
+ - [ 只能使用普通函数创建函数式组件] ( . /functional-components.html)
91
+ - [ ` functional ` attribute 在单文件组件 (SFC) 的 ` <template> ` 和 ` functional ` 组件选项中被废弃] ( . /functional-components.html)
92
+ - [ 异步组件现在需要使用 ` defineAsyncComponent ` 方法来创建] ( . /async-components.html)
94
93
- [ 组件事件现在需要在 ` emits ` 选项中声明] ( ./emits-option.md )
95
94
96
95
### 渲染函数
97
96
98
- - [ 渲染函数 API 更改] ( /guide/migration /render-function-api.html)
99
- - [ ` $scopedSlots ` property 已移除,所有插槽都通过 ` $slots ` 作为函数暴露] ( /guide/migration /slots-unification.html)
97
+ - [ 渲染函数 API 更改] ( . /render-function-api.html)
98
+ - [ ` $scopedSlots ` property 已移除,所有插槽都通过 ` $slots ` 作为函数暴露] ( . /slots-unification.html)
100
99
- [ ` $listeners ` 被移除或整合到 ` $attrs ` ] ( ./listeners-removed )
101
100
- [ ` $attrs ` 现在包含 ` class ` 和 ` style ` attribute] ( ./attrs-includes-class-style.md )
102
101
103
102
### 自定义元素
104
103
105
- - [ 自定义元素检测现在在模板编译时执行] ( /guide/migration /custom-elements-interop.html)
106
- - [ 特殊的 ` is ` attribute 的使用被严格限制在被保留的 ` <component> ` 标签中] ( /guide/migration /custom-elements-interop.html#定制内置元素)
104
+ - [ 自定义元素检测现在在模板编译时执行] ( . /custom-elements-interop.html)
105
+ - [ 特殊的 ` is ` attribute 的使用被严格限制在被保留的 ` <component> ` 标签中] ( . /custom-elements-interop.html#定制内置元素)
107
106
108
107
### 其他小改变
109
108
110
109
- ` destroyed ` 生命周期选项被重命名为 ` unmounted `
111
110
- ` beforeDestroy ` 生命周期选项被重命名为 ` beforeUnmount `
112
- - [ ` default ` prop 工厂函数不再可以访问 ` this ` 上下文] ( /guide/migration /props-default-this.html)
113
- - [ 自定义指令的 API 已更改为与组件生命周期一致,且 ` binding.expression ` 已移除] ( /guide/migration /custom-directives.html)
114
- - [ ` data ` 选项应始终被声明为一个函数] ( /guide/migration /data-option.html)
115
- - [ 来自 mixin 的 ` data ` 选项现在为浅合并] ( /guide/migration /data-option.html#mixin-合并行为变更)
116
- - [ Attribute 强制策略已更改] ( /guide/migration /attribute-coercion.html)
117
- - [ 一些过渡的 class 被重命名] ( /guide/migration /transition.html)
118
- - [ ` <TransitionGroup> ` 不再默认渲染包裹元素] ( /guide/migration /transition-group.html)
119
- - [ 当侦听一个数组时,只有当数组被替换时,回调才会触发,如果需要在变更时触发,则必须指定 ` deep ` 选项] ( /guide/migration /watch.html)
111
+ - [ ` default ` prop 工厂函数不再可以访问 ` this ` 上下文] ( . /props-default-this.html)
112
+ - [ 自定义指令的 API 已更改为与组件生命周期一致,且 ` binding.expression ` 已移除] ( . /custom-directives.html)
113
+ - [ ` data ` 选项应始终被声明为一个函数] ( . /data-option.html)
114
+ - [ 来自 mixin 的 ` data ` 选项现在为浅合并] ( . /data-option.html#mixin-合并行为变更)
115
+ - [ Attribute 强制策略已更改] ( . /attribute-coercion.html)
116
+ - [ 一些过渡的 class 被重命名] ( . /transition.html)
117
+ - [ ` <TransitionGroup> ` 不再默认渲染包裹元素] ( . /transition-group.html)
118
+ - [ 当侦听一个数组时,只有当数组被替换时,回调才会触发,如果需要在变更时触发,则必须指定 ` deep ` 选项] ( . /watch.html)
120
119
- 没有特殊指令的标记 (` v-if/else-if/else ` 、` v-for ` 或 ` v-slot ` ) 的 ` <template> ` 现在被视为普通元素,并将渲染为原生的 ` <template> ` 元素,而不是渲染其内部内容。
121
- - [ 已挂载的应用不会取代它所挂载的元素] ( /guide/migration /mount-changes.html)
122
- - [ 生命周期的 ` hook: ` 事件前缀改为 ` vnode- ` ] ( /guide/migration /vnode-lifecycle-events.html)
120
+ - [ 已挂载的应用不会取代它所挂载的元素] ( . /mount-changes.html)
121
+ - [ 生命周期的 ` hook: ` 事件前缀改为 ` vnode- ` ] ( . /vnode-lifecycle-events.html)
123
122
124
123
### 被移除的 API
125
124
126
- - [ ` keyCode ` 作为 ` v-on ` 修饰符的支持] ( /guide/migration /keycode-modifiers.html)
127
- - [ $on、$off 和 $once 实例方法] ( /guide/migration /events-api.html)
128
- - [ 过滤器 (filter)] ( /guide/migration /filters.html)
129
- - [ 内联模板 attribute] ( /guide/migration /inline-template-attribute.html)
130
- - [ ` $children ` 实例 property] ( /guide/migration /children.html)
131
- - [ ` propsData ` 选项] ( /guide/migration /props-data.html)
125
+ - [ ` keyCode ` 作为 ` v-on ` 修饰符的支持] ( . /keycode-modifiers.html)
126
+ - [ $on、$off 和 $once 实例方法] ( . /events-api.html)
127
+ - [ 过滤器 (filter)] ( . /filters.html)
128
+ - [ 内联模板 attribute] ( . /inline-template-attribute.html)
129
+ - [ ` $children ` 实例 property] ( . /children.html)
130
+ - [ ` propsData ` 选项] ( . /props-data.html)
132
131
- ` $destroy ` 实例方法。用户不应再手动管理单个 Vue 组件的生命周期。
133
132
- 全局函数 ` set ` 和 ` delete ` 以及实例方法 ` $set ` 和 ` $delete ` 。基于代理的变化检测已经不再需要它们了。
134
133
0 commit comments