fix: 优化 tabs 重载时未按照传入的 closable 正确渲染可关闭状态

pull/2566/head
贤心 2025-03-16 00:15:25 +08:00
parent bd892bf87e
commit 53ded26cb9
2 changed files with 6 additions and 9 deletions

View File

@ -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{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 .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-body{padding: 16px 0;}
.layui-tabs-item{display: none;} .layui-tabs-item{display: none;}

View File

@ -459,7 +459,7 @@ layui.define('component', function(exports) {
var that = this var that = this
var options = that.config; var options = that.config;
if(!options.closable) return; if (!options.closable) return;
opts = opts || {}; opts = opts || {};
@ -484,17 +484,13 @@ layui.define('component', function(exports) {
var that = this; var that = this;
var options = that.config; var options = that.config;
var container = that.getContainer(); var container = that.getContainer();
var hasDel = that.cache('close');
// 是否开启关闭 // 是否开启关闭
if (options.closable) { if (options.closable) {
if (!hasDel) { container.header.items.each(function() {
container.header.items.each(function(){ that.appendClose($(this));
that.appendClose($(this)); });
}); } else {
that.cache('close', true);
}
} else if(hasDel) {
container.header.items.each(function() { container.header.items.each(function() {
$(this).find('.'+ component.CONST.CLOSE).remove(); $(this).find('.'+ component.CONST.CLOSE).remove();
}); });