Skip to content

Commit d8546b5

Browse files
authored
Merge pull request #300 from xalexec/2.0-cn
typo and Circular References Between Components
2 parents a810372 + 7f545d8 commit d8546b5

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/v2/guide/components.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,9 +1078,9 @@ template: '<div><stack-overflow></stack-overflow></div>'
10781078
上面组件会导致一个错误 “max stack size exceeded” ,所以要确保递归调用有终止条件 (比如递归调用时使用 `v-if` 并让他最终返回 `false` )。
10791079

10801080

1081-
### Circular References Between Components
1081+
### 组件的循环引用
10821082

1083-
Let's say you're building a file directory tree, like in Finder or File Explorer. You might have a `tree-folder` component with this template:
1083+
你要构造一个文件树,像是 Mac 的 Finder 或是 Windows 的 资源管理器。你有一个 `tree-folder` 组件包含下面的模版:
10841084

10851085
``` html
10861086
<p>
@@ -1089,7 +1089,7 @@ Let's say you're building a file directory tree, like in Finder or File Explorer
10891089
</p>
10901090
```
10911091

1092-
Then a `tree-folder-contents` component with this template:
1092+
一个 `tree-folder-contents` 组件包含下面的模版:
10931093

10941094
``` html
10951095
<ul>
@@ -1100,25 +1100,25 @@ Then a `tree-folder-contents` component with this template:
11001100
</ul>
11011101
```
11021102

1103-
When you look closely, you'll see that these components will actually be each other's descendent _and_ ancestor in the render tree - a paradox! When registering components globally with `Vue.component`, this paradox is resolved for you automatically. If that's you, you can stop reading here.
1103+
仔细观察,你会看到组件互相依赖,这是矛盾的!当你使用 `Vue.component` 全局注册组件后,Vue 会自动解决这个问题。
11041104

1105-
However, if you're requiring/importing components using a __module system__, e.g. via Webpack or Browserify, you'll get an error:
1105+
然而,如果你使用模块化工具 Webpack 或者 Browserify,通过 requiring/importing 导入组件的话,你会看到一个错误:
11061106

11071107
```
11081108
Failed to mount component: template or render function not defined.
11091109
```
11101110

1111-
To explain what's happening, I'll call our components A and B. The module system sees that it needs A, but first A needs B, but B needs A, but A needs B, etc, etc. It's stuck in a loop, not knowing how to fully resolve either component without first resolving the other. To fix this, we need to give the module system a point at which it can say, "A needs B _eventually_, but there's no need to resolve B first."
1111+
为了解释这是如何产生的,下面我称组件为 A 和 B。模块化工具看到依赖 A,但是首先 A 依赖 B,但是 B 又依赖 A,A 又 依赖 B,如此形成了一个死循环,不知道通过先不解析另一个来解决问题,为了修复这个问题,我们需要给模块化工具一个切入点,我们可以告诉它,A 依赖 B,但是不用先解析 B。
11121112

1113-
In our case, I'll make that point the `tree-folder` component. We know the child that creates the paradox is the `tree-folder-contents` component, so we'll wait until the `beforeCreate` lifecycle hook to register it:
1113+
在我们的例子中,`tree-folder` 组件为切入点。我们知道制造矛盾的是 `tree-folder-contents` 组件,所以我在组件的生命周期钩子 `beforeCreate` 中注册它:
11141114

11151115
``` js
11161116
beforeCreate: function () {
11171117
this.$options.components.TreeFolderContents = require('./tree-folder-contents.vue')
11181118
}
11191119
```
11201120

1121-
Problem solved!
1121+
问题解决!
11221122

11231123
### 内联模版
11241124

src/v2/guide/conditional.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ new Vue({
139139
</template>
140140
```
141141

142-
现在输入文本将会在每次切换时重新渲染。自动动手试一试
142+
现在输入文本将会在每次切换时重新渲染。自己动手试一试
143143

144144
{% raw %}
145145
<div id="key-example" class="demo">

0 commit comments

Comments
 (0)