From 37a39298e1dc6e6b912a9fdcb8dc83d97ecd0b20 Mon Sep 17 00:00:00 2001 From: yyyyyyyyyyy <741369024@qq.com> Date: Thu, 9 Jan 2020 19:35:11 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#2604=20&=20#2661=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=B7=BB=E5=8A=A0tabs=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=97=B6=EF=BC=8C=E9=A1=BA=E5=BA=8F=E9=94=99?= =?UTF-8?q?=E4=B9=B1=E4=BB=A5=E5=8F=8A=E4=B8=8B=E5=88=92=E7=BA=BF=E9=95=BF?= =?UTF-8?q?=E5=BA=A6=E4=B8=8D=E5=8F=98=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= =?UTF-8?q?=20(#2663)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix 2604&2661 解决动态添加tabs列表内容时,顺序错乱以及下划线长度不变的问题。 * 修改备注 * 修改方法命名、删除相关注释 * 删除注释 --- lib/tabs/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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; } } });