Skip to content
This repository was archived by the owner on Aug 8, 2022. It is now read-only.

Commit 797f42d

Browse files
authored
update listeners-removed.md (#731)
* update listeners-removed.md * update listeners-removed.md
1 parent ed61254 commit 797f42d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/guide/migration/listeners-removed.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ badges:
88

99
## 概览
1010

11-
`$listeners` 对象在 Vue 3 中已被移除。现在事件监听器是 `$attrs` 的一部分:
11+
`$listeners` 对象在 Vue 3 中已被移除。事件监听器现在是 `$attrs` 的一部分:
1212

1313
```js
1414
{
15-
text: 'this is an attribute',
16-
onClose: () => console.log('close Event triggered')
15+
text: '这是一个 attribute',
16+
onClose: () => console.log('close 事件被触发')
1717
}
1818
```
1919

2020
## 2.x 语法
2121

22-
在 Vue 2 中,你可以使用 `this.$attrs` `this.$listeners` 分别访问传递给组件的 attribute 和事件监听器。结合 `inheritAttrs: false`,开发者可以将这些 attribute 和监听器应用到其它元素,而不是根元素
22+
在 Vue 2 中,你可以通过 `this.$attrs` 访问传递给组件的 attribute,以及通过 `this.$listeners` 访问传递给组件的事件监听器。结合 `inheritAttrs: false`,开发者可以将这些 attribute 和监听器应用到根元素之外的其它元素
2323

2424
```html
2525
<template>
@@ -36,7 +36,7 @@ badges:
3636

3737
## 3.x 语法
3838

39-
在 Vue 3 的虚拟 DOM 中,事件监听器现在只是以 `on` 为前缀的 attribute,这样就成了 `$attrs` 对象的一部分,因此 `$listeners` 被移除了。
39+
在 Vue 3 的虚拟 DOM 中,事件监听器现在只是以 `on` 为前缀的 attribute,这样它就成为了 `$attrs` 对象的一部分,因此 `$listeners` 被移除了。
4040

4141
```vue
4242
<template>
@@ -56,7 +56,7 @@ export default {
5656
```js
5757
{
5858
id: 'my-input',
59-
onClose: () => console.log('close Event triggered')
59+
onClose: () => console.log('close 事件被触发')
6060
}
6161
```
6262

@@ -69,7 +69,7 @@ export default {
6969
## 参考
7070

7171
- [相关的 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)
7373
- [迁移指南 - 渲染函数 API 的更改](./render-function-api.md)
7474
- [迁移指南 - 新增 Emits 选项](./emits-option.md)
7575
- [迁移指南 - 移除 `.native` 修饰符](./v-on-native-modifier-removed.md)

0 commit comments

Comments
 (0)