feat(table): 新增 syncFixedRowHeight 选项

fix/fixed-table-rowHeight-sync
sight 2025-09-06 00:06:45 +08:00
parent ffefdea23d
commit 588a2f69b8
1 changed files with 5 additions and 9 deletions

View File

@ -2962,20 +2962,16 @@ layui.define(['lay', 'i18n', 'laytpl', 'laypage', 'form', 'util'], function(expo
if(!that.resizeObserver) return; if(!that.resizeObserver) return;
// 显示或隐藏时重置列宽 // 显示或隐藏时重置列宽
that.resizeObserver.observe(that.elem[0], function(){ that.resizeObserver.observe(that.elem[0], that.resize.bind(that));
that.resize();
});
// 同步固定列表格和主表格高度 // 同步固定列表格和主表格高度
that.needSyncFixedColHeight = (that.layBody.length > 1) && that.needSyncFixedColHeight = that.config.syncFixedRowHeight &&
that.config.lineStyle && (that.layBody.length > 1) &&
(/\bheight\s*:\s*auto\b/g.test(that.config.lineStyle) || that.config.lineStyle.indexOf('max-height') !== -1); that.config.lineStyle
if(that.needSyncFixedColHeight){ if(that.needSyncFixedColHeight){
var tableElem = that.layMain.children('table'); var tableElem = that.layMain.children('table');
that.resizeObserver.observe(tableElem[0], function () { that.resizeObserver.observe(tableElem[0], that.syncFixedColHeight.bind(that));
that.syncFixedColHeight();
});
} }
}; };