Merge pull request #1111 from flytkgl/main

table 组件支持自适应父元素高度:#父元素ID-差距值
pull/1103/head^2
贤心 2022-08-18 10:55:04 +08:00 committed by GitHub
commit 358ec4d791
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -347,6 +347,11 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
if(options.height && /^full-\d+$/.test(options.height)){
that.fullHeightGap = options.height.split('-')[1];
options.height = _WIN.height() - that.fullHeightGap;
} else if (options.height && /^#\w+-{1}\d+$/.test(options.height)) {
var parentDiv = options.height.split("-");
that.parentHeightGap = parentDiv.pop();
that.parentDiv = parentDiv.join("-");
options.height = $(that.parentDiv).height() - that.parentHeightGap;
}
//初始化一些参数
@ -1486,6 +1491,10 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){
height = _WIN.height() - that.fullHeightGap;
if(height < 135) height = 135;
that.elem.css('height', height);
} else if (that.parentDiv && that.parentHeightGap) {
height = $(that.parentDiv).height() - that.parentHeightGap;
if (height < 135) height = 135;
that.elem.css("height", height);
}
if(!height) return;