@@ -8,18 +8,18 @@ badges:
8
8
9
9
## 概览
10
10
11
- ` $listeners ` 对象在 Vue 3 中已被移除。现在事件监听器是 ` $attrs ` 的一部分:
11
+ ` $listeners ` 对象在 Vue 3 中已被移除。事件监听器现在是 ` $attrs ` 的一部分:
12
12
13
13
``` js
14
14
{
15
- text: ' this is an attribute' ,
16
- onClose : () => console .log (' close Event triggered ' )
15
+ text: ' 这是一个 attribute' ,
16
+ onClose : () => console .log (' close 事件被触发 ' )
17
17
}
18
18
```
19
19
20
20
## 2.x 语法
21
21
22
- 在 Vue 2 中,你可以使用 ` this.$attrs ` 和 ` this.$listeners ` 分别访问传递给组件的 attribute 和事件监听器 。结合 ` inheritAttrs: false ` ,开发者可以将这些 attribute 和监听器应用到其它元素,而不是根元素 :
22
+ 在 Vue 2 中,你可以通过 ` this.$attrs ` 访问传递给组件的 attribute,以及通过 ` this.$listeners ` 访问传递给组件的事件监听器 。结合 ` inheritAttrs: false ` ,开发者可以将这些 attribute 和监听器应用到根元素之外的其它元素 :
23
23
24
24
``` html
25
25
<template >
@@ -36,7 +36,7 @@ badges:
36
36
37
37
## 3.x 语法
38
38
39
- 在 Vue 3 的虚拟 DOM 中,事件监听器现在只是以 ` on ` 为前缀的 attribute,这样就成了 ` $attrs ` 对象的一部分,因此 ` $listeners ` 被移除了。
39
+ 在 Vue 3 的虚拟 DOM 中,事件监听器现在只是以 ` on ` 为前缀的 attribute,这样它就成为了 ` $attrs ` 对象的一部分,因此 ` $listeners ` 被移除了。
40
40
41
41
``` vue
42
42
<template>
@@ -56,7 +56,7 @@ export default {
56
56
``` js
57
57
{
58
58
id: ' my-input' ,
59
- onClose : () => console .log (' close Event triggered ' )
59
+ onClose : () => console .log (' close 事件被触发 ' )
60
60
}
61
61
```
62
62
@@ -69,7 +69,7 @@ export default {
69
69
## 参考
70
70
71
71
- [ 相关的 RFC] ( https://github.com/vuejs/rfcs/blob/master/active-rfcs/0031-attr-fallthrough.md )
72
- - [ 迁移指南 - ` $attrs ` 包括 ` class ` 和 ` style ` ] ( ./attrs-includes-class-style.md )
72
+ - [ 迁移指南 - ` $attrs ` 包含 ` class ` 和 ` style ` ] ( ./attrs-includes-class-style.md )
73
73
- [ 迁移指南 - 渲染函数 API 的更改] ( ./render-function-api.md )
74
74
- [ 迁移指南 - 新增 Emits 选项] ( ./emits-option.md )
75
75
- [ 迁移指南 - 移除 ` .native ` 修饰符] ( ./v-on-native-modifier-removed.md )
0 commit comments