Skip to content

Commit

Permalink
Merge pull request #42 from stanJ/patch-1
Browse files Browse the repository at this point in the history
Update create-element.md
  • Loading branch information
ustbhuangyi committed Jan 31, 2019
2 parents 0d47e52 + a902d42 commit 8d1c0d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/data-driven/create-element.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function normalizeChildren (children: any): ?Array<VNode> {
}
```

`simpleNormalizeChildren` 方法调用场景是 `render` 函数当函数是编译生成的。理论上编译生成的 `children` 都已经是 VNode 类型的,但这里有一个例外,就是 `functional component` 函数式组件返回的是一个数组而不是一个根节点,所以会通过 `Array.prototype.concat` 方法把整个 `children` 数组打平,让它的深度只有一层。
`simpleNormalizeChildren` 方法调用场景是 `render` 函数是编译生成的。理论上编译生成的 `children` 都已经是 VNode 类型的,但这里有一个例外,就是 `functional component` 函数式组件返回的是一个数组而不是一个根节点,所以会通过 `Array.prototype.concat` 方法把整个 `children` 数组打平,让它的深度只有一层。

`normalizeChildren` 方法的调用场景有 2 种,一个场景是 `render` 函数是用户手写的,当 `children` 只有一个节点的时候,Vue.js 从接口层面允许用户把 `children` 写成基础类型用来创建单个简单的文本节点,这种情况会调用 `createTextVNode` 创建一个文本节点的 VNode;另一个场景是当编译 `slot``v-for` 的时候会产生嵌套数组的情况,会调用 `normalizeArrayChildren` 方法,接下来看一下它的实现:

Expand Down

0 comments on commit 8d1c0d8

Please sign in to comment.