From bbc4f0467eac9418fa0f45f2d497eee54d10adf6 Mon Sep 17 00:00:00 2001 From: morning-star <26325820+Sight-wcg@users.noreply.github.com> Date: Fri, 29 Aug 2025 17:50:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(tabs):=20=E4=BF=AE=E5=A4=8D=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=A0=87=E7=AD=BE=E5=86=85=E5=AE=B9=E9=A1=B9=20lay-id?= =?UTF-8?q?=20=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6=E4=BC=9A=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=9C=80=E5=90=8E=E4=B8=80=E9=A1=B9=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#2806)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/tabs.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/tabs.js b/src/modules/tabs.js index ca188943..777ac4d0 100644 --- a/src/modules/tabs.js +++ b/src/modules/tabs.js @@ -685,8 +685,9 @@ layui.define('component', function(exports) { return bodyItem[0] ? bodyItem : function() { // 若未匹配到 lay-id 对应内容项,则通过对应头部项的索引匹配内容项 var headerItems = container.header.items; - var headerItem = headerItems.filter('[lay-id="'+ index +'"]'); - return bodyItems.eq(headerItem.index()); + var headerItemIndex = headerItems.filter('[lay-id="'+ index +'"]').index(); + + return headerItemIndex !== -1 ? bodyItems.eq(headerItemIndex) : bodyItem; }(); } @@ -703,12 +704,13 @@ layui.define('component', function(exports) { var container = that.getContainer(); var thisHeaderItem = container.header.items.filter('.'+ component.CONST.CLASS_THIS); var index = thisHeaderItem.index(); + var layid = thisHeaderItem.attr('lay-id'); return { options: options, // 标签配置信息 container: container, // 标签容器的相关元素 thisHeaderItem: thisHeaderItem, // 当前活动标签头部项 - thisBodyItem: that.findBodyItem(index), // 当前活动标签内容项 + thisBodyItem: that.findBodyItem(layid || index), // 当前活动标签内容项 index: index, // 当前活动标签索引 length: container.header.items.length // 标签数量 };