在Antd中,用于指定表格列宽度的单位是像素(px)。可以通过设置width
属性来指定表格列的宽度。
以下是一个示例代码:
import React from 'react';
import { Table } from 'antd';
const columns = [
{
title: 'Name',
dataIndex: 'name',
width: 200, // 设置列宽度为200px
},
{
title: 'Age',
dataIndex: 'age',
width: 100, // 设置列宽度为100px
},
{
title: 'Address',
dataIndex: 'address',
},
];
const data = [
{
key: '1',
name: 'John Doe',
age: 30,
address: 'New York',
},
// 更多数据...
];
const App = () => {
return (
);
}
export default App;
在上面的代码中,我们通过设置width
属性来指定表格的列宽度。name
列的宽度为200px,age
列的宽度为100px,address
列的宽度将自动适应剩余空间。
请注意,如果未指定列的宽度,则该列将自动调整为适应内容的宽度。