要改变可展开的"+"列的宽度,可以使用Ant Design的Table组件中的expandable属性来自定义展开列的宽度。
以下是一个使用ANTD Pro表格的示例代码,展示如何改变可展开列的宽度:
import React from 'react';
import { Table } from 'antd';
import { PlusOutlined, MinusOutlined } from '@ant-design/icons';
const data = [
{
key: '1',
name: 'John Brown',
age: 32,
address: 'New York No. 1 Lake Park',
description: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',
},
{
key: '2',
name: 'Jim Green',
age: 42,
address: 'London No. 1 Lake Park',
description: 'My name is Jim Green, I am 42 years old, living in London No. 1 Lake Park.',
},
// ... more data
];
const columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
},
{
title: 'Age',
dataIndex: 'age',
key: 'age',
},
{
title: 'Address',
dataIndex: 'address',
key: 'address',
},
{
title: 'Action',
key: 'action',
width: 50, // 设置展开列的宽度
render: (_, record) => (
{record.expand ? (
) : (
)}
),
},
];
const ExpandableTable = () => {
const expandable = {
expandedRowRender: (record) => (
{record.description}
),
expandIconColumnIndex: 3, // 设置展开图标所在的列
};
return (
);
};
export default ExpandableTable;
在上面的代码中,我们通过设置columns数组中的width属性来改变展开列的宽度。在render函数中,我们使用了Ant Design的PlusOutlined和MinusOutlined图标来表示展开和收起的状态。在expandable对象中,我们通过expandIconColumnIndex属性来指定展开图标所在的列。
你可以根据自己的需求调整展开列的宽度,并自定义展开图标的样式。