Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
errorrik committed Feb 17, 2021
1 parent bf08752 commit 6addcb7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/view/async-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@ AsyncComponent.prototype.onload = function (ComponentClass) {

var parent = this.options.parent;

// 如果异步组件时root节点,则更新为root节点
if (parent._rootNode === this) {
// 如果异步组件为 root 节点,直接更新
parent._rootNode = component;
component._getElAsRootNode && (parent.el = component._getElAsRootNode());
} else {
// 原本的逻辑
// 在 children 中查找
var parentChildren = parent.children;

// children 中存在多个 AsyncComponent 时,只循环一遍,为所有 AsyncComponent 的 parentIndex 赋值
if (this.parentIndex == null || parentChildren[this.parentIndex] !== this) {
each(parentChildren, function (child, index) {
if (child instanceof AsyncComponent) {
Expand Down

0 comments on commit 6addcb7

Please sign in to comment.