[React]解决AntDesign表格宽度缩小后,表头折叠的问题

 
应该给每个 column 设定 minWidth,而不是 width

 

  const columns: TableColumnsType<LogItem> = useMemo(
    () => [
      {
        title: '序号',
        dataIndex: 'index',
        key: 'index',
        minWidth: 60,
        render: (text, record, index) => `${index + 1}`,
      },
      {
        title: '名称',
        dataIndex: 'name',
        key: 'name',
        render: () => `${info?.name}`,
        minWidth: 150,
      },
      {
        title: '表名称',
        dataIndex: 'TableName',
        key: 'TableName',
        minWidth: 150,
      },
      {
        title: '状态',
        dataIndex: 'status',
        key: 'status',
        minWidth: 60,
        render(value) {
          return value == 1 ? '成功' : '失败';
        },
      },
    ],
    [],
  );
return (
<Table style={{ flex: 1, overflowY: 'auto' }} rowKey="id" columns={columns} dataSource={info?.logList}
/> );

 

posted @ 2024-12-20 10:45  夕苜19  阅读(2)  评论(0编辑  收藏  举报