You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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`组件包含下面的模版:
1084
1084
1085
1085
```html
1086
1086
<p>
@@ -1089,7 +1089,7 @@ Let's say you're building a file directory tree, like in Finder or File Explorer
1089
1089
</p>
1090
1090
```
1091
1091
1092
-
Then a `tree-folder-contents`component with this template:
1092
+
一个 `tree-folder-contents`组件包含下面的模版:
1093
1093
1094
1094
```html
1095
1095
<ul>
@@ -1100,25 +1100,25 @@ Then a `tree-folder-contents` component with this template:
1100
1100
</ul>
1101
1101
```
1102
1102
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.
Failed to mount component: template or render function not defined.
1109
1109
```
1110
1110
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。
1112
1112
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:
0 commit comments