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

Commit ed7a93c

Browse files
author
Aaron
authored
Merge pull request #2 from vuejs/master
update repository
2 parents 35f3b76 + 35abaac commit ed7a93c

File tree

5 files changed

+33
-38
lines changed

5 files changed

+33
-38
lines changed

src/api/composition-api.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,9 @@ const foo = inject<string>('foo') // string | undefined
167167
- [Provide / Inject](../guide/component-provide-inject.html)
168168
- [组合式 API Provide / Inject](../guide/composition-api-provide-inject.html)
169169

170-
<!-- TODO: translation -->
171-
172170
## `getCurrentInstance`
173171

174-
`getCurrentInstance` enables access to an internal component instance useful for advanced usages or for library creators.
172+
`getCurrentInstance` 支持访问内部组件实例,用于高阶用法或库的开发。
175173

176174
```ts
177175
import { getCurrentInstance } from 'vue'
@@ -180,14 +178,14 @@ const MyComponent = {
180178
setup() {
181179
const internalInstance = getCurrentInstance()
182180
183-
internalInstance.appContext.config.globalProperties // access to globalProperties
181+
internalInstance.appContext.config.globalProperties // 访问 globalProperties
184182
}
185183
}
186184
```
187185

188-
`getCurrentInstance` **only** works during [setup](#setup) or [Lifecycle Hooks](#lifecycle-hooks)
186+
`getCurrentInstance` **只能**[setup](#setup) 或[生命周期钩子](#lifecycle-hooks)中调用。
189187

190-
> When using outside of [setup](#setup) or [Lifecycle Hooks](#lifecycle-hooks), please call `getCurrentInstance()` on `setup` and use the instance instead.
188+
> 如需在 [setup](#setup) 或[生命周期钩子](#lifecycle-hooks)外使用,请先在 `setup` 中调用 `getCurrentInstance()` 获取该实例然后再使用。
191189

192190
```ts
193191
const MyComponent = {
@@ -218,7 +216,7 @@ const MyComponent = {
218216
}
219217
}
220218
221-
// also works if called on a composable
219+
// 在组合式函数中调用也可以正常执行
222220
function useComponentId() {
223221
return getCurrentInstance().uid
224222
}

src/guide/component-slots.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 插槽
22

3-
> 该页面假设你已经阅读过了[组件基础](component-basics.md)如果你还对组件不太了解,推荐你先阅读它。
3+
> 该页面假设你已经阅读过了[组件基础](component-basics.md)如果你对组件还不太了解,推荐你先阅读它。
44
55
## 插槽内容
66

@@ -96,17 +96,17 @@ Vue 实现了一套内容分发的 API,这套 API 的设计灵感源自 [Web C
9696

9797
> 父级模板里的所有内容都是在父级作用域中编译的;子模板里的所有内容都是在子作用域中编译的。
9898
99-
## 后备内容
99+
## 备用内容
100100

101-
有时为一个插槽设置具体的后备 (也就是默认的) 内容是很有用的,它只会在没有提供内容的时候被渲染。例如在一个 `<submit-button>` 组件中:
101+
有时为一个插槽设置具体的备用 (也就是默认的) 内容是很有用的,它只会在没有提供内容的时候被渲染。例如在一个 `<submit-button>` 组件中:
102102

103103
```html
104104
<button type="submit">
105105
<slot></slot>
106106
</button>
107107
```
108108

109-
我们可能希望这个 `<button>` 内绝大多数情况下都渲染文本“Submit”。为了将“Submit”作为后备内容,我们可以将它放在 `<slot>` 标签内:
109+
我们可能希望这个 `<button>` 内绝大多数情况下都渲染文本“Submit”。为了将“Submit”作为备用内容,我们可以将它放在 `<slot>` 标签内:
110110

111111
```html
112112
<button type="submit">
@@ -120,7 +120,7 @@ Vue 实现了一套内容分发的 API,这套 API 的设计灵感源自 [Web C
120120
<submit-button></submit-button>
121121
```
122122

123-
后备内容“Submit”将会被渲染:
123+
备用内容“Submit”将会被渲染:
124124

125125
```html
126126
<button type="submit">
@@ -136,7 +136,7 @@ Vue 实现了一套内容分发的 API,这套 API 的设计灵感源自 [Web C
136136
</submit-button>
137137
```
138138

139-
则这个提供的内容将会被渲染从而取代后备内容
139+
则这个提供的内容将会被渲染从而取代备用内容
140140

141141
```html
142142
<button type="submit">
@@ -243,7 +243,7 @@ app.component('todo-list', {
243243
})
244244
```
245245

246-
我们可能需要替换插槽以在父组件上自定义它
246+
我们可能需要替换插槽使它作用在父组件上
247247

248248
```html
249249
<todo-list>
@@ -356,7 +356,7 @@ function (slotProps) {
356356
</todo-list>
357357
```
358358

359-
你甚至可以定义后备内容,用于插槽 prop 是 undefined 的情形:
359+
你甚至可以定义备用内容,用于插槽 prop 是 undefined 的情形:
360360

361361
```html
362362
<todo-list v-slot="{ item = 'Placeholder' }">

src/guide/composition-api-setup.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ setup(props) {
4848
}
4949
```
5050

51-
<!-- TODO: translation -->
5251

53-
If `title` is an optional prop, it could be missing from `props`. In that case, `toRefs` won't create a ref for `title`. Instead you'd need to use `toRef`:
52+
如果 `title` 是可选的 prop,则传入的 `props` 中可能没有 `title` 。在这种情况下,`toRefs` 将不会为 `title` 创建一个 ref 。你需要使用 `toRef` 替代它:
5453

5554
```js
5655
// MyBook.vue
@@ -61,7 +60,7 @@ setup(props) {
6160
}
6261
```
6362

64-
### 上下文
63+
### Context
6564

6665
传递给 `setup` 函数的第二个参数是 `context``context` 是一个普通的 JavaScript 对象,它暴露三个组件的 property:
6766

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
---
2-
title: v-on.native modifier removed
2+
title: 移除 v-on.native 修饰符
33
badges:
44
- breaking
55
---
66

7-
<!-- TODO: translation -->
7+
# 移除 `v-on.native` 修饰符 <MigrationBadges :badges="$frontmatter.badges" />
88

9-
# `v-on.native` modifier removed <MigrationBadges :badges="$frontmatter.badges" />
9+
## 概览
1010

11-
## Overview
11+
`v-on``.native` 修饰符已被移除。
1212

13-
The `.native` modifier for `v-on` has been removed.
13+
## 2.x 语法
1414

15-
## 2.x Syntax
16-
17-
Event listeners passed to a component with `v-on` are by default only triggered by emitting an event with `this.$emit`. To add a native DOM listener to the child component's root element instead, the `.native` modifier can be used:
15+
默认情况下,传递给带有 `v-on` 的组件的事件监听器只有通过 `this.$emit` 才能触发。要将原生 DOM 监听器添加到子组件的根元素中,可以使用 `.native` 修饰符:
1816

1917
```html
2018
<my-component
@@ -23,11 +21,11 @@ Event listeners passed to a component with `v-on` are by default only triggered
2321
/>
2422
```
2523

26-
## 3.x Syntax
24+
## 3.x 语法
2725

28-
The `.native` modifier for `v-on` has been removed. At the same time, the [new `emits` option](./emits-option.md) allows the child to define which events it does indeed emit.
26+
`v-on` `.native` 修饰符已被移除。同时,[新增的 `emits` 选项](./emits-option.md)允许子组件定义真正会被触发的事件。
2927

30-
Consequently, Vue will now add all event listeners that are _not_ defined as component-emitted events in the child as native event listeners to the child's root element (unless `inheritAttrs: false` has been set in the child's options).
28+
因此,对于子组件中**被定义为组件触发的所有事件监听器,Vue 现在将把它们作为原生事件监听器添加到子组件的根元素中 (除非在子组件的选项中设置了 `inheritAttrs: false`)。
3129

3230
```html
3331
<my-component
@@ -46,14 +44,14 @@ Consequently, Vue will now add all event listeners that are _not_ defined as com
4644
</script>
4745
```
4846

49-
## Migration Strategy
47+
## 迁移策略
5048

51-
- remove all instances of the `.native` modifier.
52-
- ensure that all your components document their events with the `emits` option.
49+
- 删除 `.native` 修饰符的所有实例。
50+
- 确保所有组件都使用 `emits` 选项记录其事件。
5351

54-
## See also
52+
## 参考
5553

56-
- [Relevant RFC](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0031-attr-fallthrough.md#v-on-listener-fallthrough)
57-
- [Migration guide - New Emits Option](./emits-option.md)
58-
- [Migration guide - `$listeners` removed](./listeners-removed.md)
59-
- [Migration guide - Changes in the Render Functions API](./render-function-api.md)
54+
- [相关的 RFC](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0031-attr-fallthrough.md#v-on-listener-fallthrough)
55+
- [迁移指南 - 新增 Emits 选项](./emits-option.md)
56+
- [迁移指南 - 移除 `$listeners`](./listeners-removed.md)
57+
- [迁移指南 - 渲染函数 API 的更改](./render-function-api.md)

src/guide/render-function.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ render() {
338338
// 如果触发事件的元素不是事件绑定的元素
339339
// 则返回
340340
if (event.target !== event.currentTarget) return
341-
// 如果向上键不是回车键,则中止
341+
// 如果向上键不是回车键,则终止
342342
// 没有同时按下按键 (13) 和 shift 键
343343
if (!event.shiftKey || event.keyCode !== 13) return
344344
// 停止事件传播

0 commit comments

Comments
 (0)