From 7c1a9a050da8bede0eff8b0cd2a6ea4dc348c7b8 Mon Sep 17 00:00:00 2001 From: sight <1453017105@qq.com> Date: Fri, 1 Dec 2023 11:17:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=20table=20height=20=E9=80=89?= =?UTF-8?q?=E9=A1=B9=EF=BC=8C=E6=94=AF=E6=8C=81=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close https://gitee.com/layui/layui/issues/I8KR5U --- src/modules/table.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 2b0d7ef4..23bc4812 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -360,6 +360,9 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ that.parentHeightGap = parentDiv.pop(); that.parentDiv = parentDiv.join("-"); options.height = $(that.parentDiv).height() - (parseFloat(that.parentHeightGap) || 0); + } else if (typeof options.height === "function"){ + that.customHeightFunc = options.height; + options.height = that.customHeightFunc(); } // 开始插入替代元素 @@ -1727,15 +1730,19 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ var options = that.config; var height = options.height; var bodyHeight; + var MIN_HEIGHT = 135; if(that.fullHeightGap){ height = _WIN.height() - that.fullHeightGap; - if(height < 135) height = 135; + if(height < MIN_HEIGHT) height = MIN_HEIGHT; // that.elem.css('height', height); } else if (that.parentDiv && that.parentHeightGap) { height = $(that.parentDiv).height() - that.parentHeightGap; - if (height < 135) height = 135; + if(height < MIN_HEIGHT) height = MIN_HEIGHT; // that.elem.css("height", height); + } else if (that.customHeightFunc) { + height = that.customHeightFunc(); + if(height < MIN_HEIGHT) height = MIN_HEIGHT; } // 如果多级表头,则填补表头高度