From 419fc8da27b3c6b98c35d37634c1449eef16755f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Thu, 2 Mar 2023 00:11:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20`tab`=20=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=8B=E6=A0=87=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/element.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/modules/element.js b/src/modules/element.js index c6ff3678..1a46f82e 100644 --- a/src/modules/element.js +++ b/src/modules/element.js @@ -113,14 +113,16 @@ layui.define('jquery', function(exports){ //Tab 点击 tabClick: function(e, index, liElem, options){ options = options || {}; - var othis = liElem || $(this) - ,index = index || othis.parent().children('li').index(othis) - ,parents = options.headerElem ? othis.parent() : othis.parents('.layui-tab').eq(0) - ,item = options.bodyElem ? $(options.bodyElem) : parents.children('.layui-tab-content').children('.layui-tab-item') - ,elemA = othis.find('a') - ,isJump = elemA.attr('href') !== 'javascript:;' && elemA.attr('target') === '_blank' //是否存在跳转 - ,unselect = typeof othis.attr('lay-unselect') === 'string' //是否禁用选中 - ,filter = parents.attr('lay-filter'); + index = index === undefined + ? othis.parent().children('li').index(othis) + : index; + var othis = liElem || $(this); + var parents = options.headerElem ? othis.parent() : othis.parents('.layui-tab').eq(0); + var item = options.bodyElem ? $(options.bodyElem) : parents.children('.layui-tab-content').children('.layui-tab-item'); + var elemA = othis.find('a'); + var isJump = elemA.attr('href') !== 'javascript:;' && elemA.attr('target') === '_blank'; //是否存在跳转 + var unselect = typeof othis.attr('lay-unselect') === 'string'; //是否禁用选中 + var filter = parents.attr('lay-filter'); //执行切换 if(!(isJump || unselect)){ @@ -177,8 +179,8 @@ layui.define('jquery', function(exports){ call.hideTabMore(true) } - //允许关闭 - if(othis.attr('lay-allowClose')){ + // 开启关闭图标 + if(othis.attr('lay-allowclose')){ title.find('li').each(function(){ var li = $(this); if(!li.find('.'+CLOSE)[0]){