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

Commit 3dc6734

Browse files
authored
Merge pull request #146 from GeekQiaQia/master
update-template-refs
2 parents ab8aed4 + 8135f7c commit 3dc6734

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/guide/composition-api-template-refs.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
## 模板引用
22

3-
> 本节使用[单文件组件](single-file-component.html)代码示例的语法
3+
> 本节代码示例使用[单文件组件](single-file-component.html)的语法
44
5-
> 本指南假定你已经阅读了 [Composition API 简介](composition-api-introduction.html)[响应式基础](reactivity-fundamentals.html)。如果你不熟悉组合 API,请先阅读这篇文章
5+
> 本指南假定你已经阅读了 [Composition API 简介](composition-api-introduction.html)[响应式基础](reactivity-fundamentals.html)。如果你不熟悉组合 API,请先阅读此文章
66
77
在使用组合 API 时,[响应式引用](reactivity-fundamentals.html#creating-standalone-reactive-values-as-refs)[模板引用](component-template-refs.html)的概念是统一的。为了获得对模板内元素或组件实例的引用,我们可以像往常一样声明 ref 并从 [setup ()](composition-api-setup.html) 返回:
88

99
```html
10-
<template>
10+
<template>
1111
<div ref="root">This is a root element</div>
1212
</template>
1313

@@ -31,11 +31,11 @@
3131
</script>
3232
```
3333

34-
这里我们在渲染上下文中暴露 `root`,并通过 `ref="root"`,将其绑定到 div 作为其 ref。在虚拟 DOM 修补算法中,如果 VNode 的 `ref` 键对应于渲染上下文中的 ref,则 VNode 的相应元素或组件实例将被分配给该 ref 的值。这是在虚拟 DOM 挂载/打补丁过程中执行的,因此模板引用只会在初始渲染之后获得赋值。
34+
这里我们在渲染上下文中暴露 `root`,并通过 `ref="root"`,将其绑定到 div 作为其 ref。在虚拟 DOM 补丁算法中,如果 VNode 的 `ref` 键对应于渲染上下文中的 ref,则 VNode 的相应元素或组件实例将被分配给该 ref 的值。这是在虚拟 DOM 挂载/打补丁过程中执行的,因此模板引用只会在初始渲染之后获得赋值。
3535

36-
作为模板使用的 ref 的行为与任何其他 ref 一样:它们是响应式的,可以传递到 (或从) 复合函数中返回
36+
作为模板使用的 ref 的行为与任何其他 ref 一样:它们是响应式的,可以传递到 (或从中返回) 复合函数中
3737

38-
### JSX的用法
38+
### JSX 中的用法
3939

4040
```js
4141
export default {
@@ -53,7 +53,7 @@ export default {
5353
}
5454
```
5555

56-
### 内部使用 `v-for`
56+
### `v-for` 中的用法
5757

5858
Composition API 模板引用在 `v-for` 内部使用时没有特殊处理。相反,请使用函数引用执行自定义处理:
5959

0 commit comments

Comments
 (0)