我在最新的文章里,做了较为详细的解释
前段日子画了一个表格,总结下这个合并的问题。
表格如图所示:
image.png
const columns = [{
title: '服务、费用及结算',
children: [{
title: '服务名称',
dataIndex: 'serviceName',
key: 'serviceName',
}, {
title: '特殊规则',
dataIndex: 'serviceDesc',
key: 'serviceDesc',
render(value, row, index) {
const obj = {
children: value,
props: {},
};
// 第二列的第三行合并,占三个空格
if (index === 1) {
obj.props.colSpan = 3;
}
// 第二列的第四行合并,占三个空格
if (index === 2) {
obj.props.colSpan = 3;
}
return obj;
},
}, {
title: '价格',
dataIndex: 'price',
key: 'price',
}, {
title: '优惠策略',
dataIndex: 'ploy',
key: 'ploy',
render(value, row, index) {
const obj = {
children: value,
props: {},
};
//第四列的第二、三行,设置rosSpan为0,直接不渲染
if (index === 4) {
obj.props.rowSpan = 0;
}
if (index === 1) {
obj.props.colSpan = 0;
}
if (index === 2) {
obj.props.colSpan = 0;
}
return obj;
},
}, {
title: '说明',
dataIndex: 'desc',
key: 'desc',
render(value, row, index) {
const obj = {
children: value,
props: {},
};
if (index === 5) {
obj.props.rowSpan = 0;
}
if (index === 1) {
obj.props.colSpan = 0;
}
if (index === 2) {
obj.props.colSpan = 0;
}
return obj;
},
}],
}];
网友评论