方法1
简单粗暴,直接数有多少行是重复数据,index%重复总数 === n
,最上面是0,下面依次是从第几行开始需要重复数据的行数。
import React from 'react';
import {
Table } from 'antd';
class tableInfo extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
columns: [{
title:'姓名',
dataIndex:'name',
key:'name',
children: [{
title:'姓',
dataIndex:'lastName',
key:'lastName',
render: (value, row, index) => {
const obj = {
children: value,
props: {
},
};
if(index%37 === 0) {
obj.props.rowSpan = 4;
} else if(index%37 === 4) {
obj.props.rowSpan = 33;
} else {
obj.props.rowSpan = 0;
}
return obj;
}
},{
title:'名',
dataIndex:'firstName',
key:'firstName',
render: (value, row, index) => {
const obj = {
children: value,
props: {
},
};