1
MegrezZhu 2022-02-26 17:34:52 +08:00 1
啥花里胡哨的 |
2
binux 2022-02-26 17:55:43 +08:00
function renderRowSpan(index) {
for (let i of mergeTable) { if (index == 0) return { rowSpan: i }; if (index < 0) return { rowSpan: 0 }; index -= i; } if (index < 0) return { rowSpan: 0 }; } |
3
DingDingDang123 OP @binux 大佬,太感谢了,测试可行,这就是我想要的效果
|
4
DingDingDang123 OP @MegrezZhu 感谢大佬,样式很漂亮,就是不能复制,不好测试。
|
5
sweetcola 2022-02-26 20:59:17 +08:00
const renderRowSpan = data => data.reduce((t, c) => ([...t, { rowSpan: c }, ...new Array(c - 1).fill({ rowSpan: 0 })]), []);
|
6
Cbdy 2022-02-26 21:08:42 +08:00
@DingDingDang123 升级一下 Monterey 就可以复制了
|
7
des 2022-02-26 23:24:55 +08:00
用 flat 更简洁易懂一点,顺便给你做了错误处理
const makeRowSpan = i => ({ rowSpan: i }) const makeRowBySpanNum = num => [makeRowSpan(num), ...new Array(--num).fill(makeRowSpan(0))] const makeSpan = rows => rows?.filter(Number.isFinite).map(makeRowBySpanNum).flat() ?? [] makeSpan([2,3,3,null,2]) |