From 53ded26cb96009330977320b5991bbcd17468eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sun, 16 Mar 2025 00:15:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=20tabs=20=E9=87=8D?= =?UTF-8?q?=E8=BD=BD=E6=97=B6=E6=9C=AA=E6=8C=89=E7=85=A7=E4=BC=A0=E5=85=A5?= =?UTF-8?q?=E7=9A=84=20closable=20=E6=AD=A3=E7=A1=AE=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E5=8F=AF=E5=85=B3=E9=97=AD=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/layui.css | 1 + src/modules/tabs.js | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/css/layui.css b/src/css/layui.css index f0c54bce..a16e8589 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -1317,6 +1317,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh .layui-tabs-header li .layui-tabs-close{position: relative; display: inline-block; width: 16px; height: 16px; line-height: 18px; margin-left: 8px; top: 0px; text-align: center; font-size: 12px; color: #959595; border-radius: 50%; font-weight: 700; transition: all .16s; -webkit-transition: all .16s;} .layui-tabs-header li .layui-tabs-close:hover{ background-color: #ff5722; color: #fff;} +.layui-tabs-header li[lay-closable="false"] .layui-tabs-close{display: none;} .layui-tabs-body{padding: 16px 0;} .layui-tabs-item{display: none;} diff --git a/src/modules/tabs.js b/src/modules/tabs.js index 4c1ab889..b34802a0 100644 --- a/src/modules/tabs.js +++ b/src/modules/tabs.js @@ -459,7 +459,7 @@ layui.define('component', function(exports) { var that = this var options = that.config; - if(!options.closable) return; + if (!options.closable) return; opts = opts || {}; @@ -484,17 +484,13 @@ layui.define('component', function(exports) { var that = this; var options = that.config; var container = that.getContainer(); - var hasDel = that.cache('close'); // 是否开启关闭 if (options.closable) { - if (!hasDel) { - container.header.items.each(function(){ - that.appendClose($(this)); - }); - that.cache('close', true); - } - } else if(hasDel) { + container.header.items.each(function() { + that.appendClose($(this)); + }); + } else { container.header.items.each(function() { $(this).find('.'+ component.CONST.CLOSE).remove(); });