Skip to content

Commit 56c2175

Browse files
committed
完善虚拟滚动动态高度逻辑
1 parent 07da24d commit 56c2175

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/ve-table/src/index.jsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,11 @@ export default {
216216
rowKey: "",
217217
columnKey: "",
218218
},
219-
// table offest height
219+
/*
220+
table offest height(开启虚拟滚动时使用)
221+
1、当 :max-height="500" 时使用 max-height
222+
2、当 max-height="calc(100vh - 210px)" 或者 max-height="80%" 时使用 tableOffestHeight
223+
*/
220224
tableOffestHeight: 0,
221225
};
222226
},
@@ -244,16 +248,21 @@ export default {
244248
isVirtualScroll,
245249
virtualScrollOption,
246250
defaultVirtualScrollMinRowHeight,
251+
maxHeight,
247252
tableOffestHeight,
248253
} = this;
249254

250-
if (isVirtualScroll && tableOffestHeight) {
255+
if (isVirtualScroll && maxHeight) {
251256
const minRowHeight = isNumber(virtualScrollOption.minRowHeight)
252257
? virtualScrollOption.minRowHeight
253258
: defaultVirtualScrollMinRowHeight;
254259

255-
// 修复当动态高度 max-height="calc(100vh - 210px)" 时无法计算的问题
256-
result = Math.ceil(tableOffestHeight / minRowHeight);
260+
if (isNumber(maxHeight)) {
261+
result = Math.ceil(maxHeight / minRowHeight);
262+
} else if (tableOffestHeight) {
263+
// 修复当动态高度 当 max-height="calc(100vh - 210px)" 或者 max-height="80%" 时无法计算的问题
264+
result = Math.ceil(tableOffestHeight / minRowHeight);
265+
}
257266
}
258267
return result;
259268
},

0 commit comments

Comments
 (0)