diff --git a/lib/tabs/index.js b/lib/tabs/index.js index c50204e5..02cb1033 100644 --- a/lib/tabs/index.js +++ b/lib/tabs/index.js @@ -10,9 +10,9 @@ component_1.VantComponent({ name: 'tab', type: 'descendant', linked: function (target) { - target.index = this.children.length; - this.children.push(target); + this.children = this.getChildren(); this.updateTabs(); + this.setLine(); }, unlinked: function (target) { this.children = this.children @@ -22,6 +22,7 @@ component_1.VantComponent({ return child; }); this.updateTabs(); + this.setLine(); } }, props: { @@ -282,6 +283,14 @@ component_1.VantComponent({ this.setCurrentIndex(currentIndex + 1); } } + }, + getChildren: function () { + var nodes = this.getRelationNodes('../tab/index') + nodes.map((child, index) => { + child.index = index; + return child; + }) + return nodes; } } });