Antd 表格在表头中如果有子行,就会在表头文本前自动添加一个 +
符号。要去掉该符号,可以在表头文本前使用空格占位,或者使用自定义表头来解决。
示例代码:
import { Table } from 'antd';
const columns = [
{
title: '姓名',
dataIndex: 'name',
key: 'name',
render: (text) => {text},
},
{
title: '年龄',
key: 'age',
dataIndex: 'age',
render: (text) => {text},
},
// 在表头文本前使用空格占位
{
title: ' ',
dataIndex: ' ',
key: ' ',
render: () => '',
},
{
title: '地址',
children: [
{
title: '省份',
dataIndex: 'province',
key: 'province',
render: (text) => {text},
},
{
title: '城市',
dataIndex: 'city',
key: 'city',
render: (text) => {text},
},
],
},
];
const data = [
{
key: '1',
name: 'John Brown',
age: 32,
province: 'New York',
city: 'New York',
},
{
key: '2',
name: 'Jim Green',
age: 42,
province: 'London',
city: 'London',
},
{
key: '3',
name: 'Joe Black',
age: 32,
province: 'Sidney',
city: 'Sidney',
},
];
;
上一篇:Antd表格跳过页面:无数据
下一篇:Antd表格行上的提示框