最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - Ant Table fixed column width - Stack Overflow

programmeradmin0浏览0评论
  1. The column width is not set via the width property.
  2. If you set the width of the cells, the column will still stretch if the table container is enlarged.

Can you tell me, has anyone come across such a case?

my code:

  const columns = [
    {
      key: "a",
      dataIndex: "a",
      title: "A",
      width: "100px",
    },
    {
      key: "b",
      dataIndex: "b",
      title: "B",
      width: "50px",
    },
    {
      key: "c",
      dataIndex: "c",
      title: "C",
      width: "100px",
    },
    {
      key: "d",
      dataIndex: "d",
      title: "D",
      width: "100px",
    },

    {
      key: "e",
      dataIndex: "e",
      title: "E",
      width: "100px",
    },
  ];

  const dataSource = [
    { a: 1, b: 2, c: 3, d: 4, e: 5 },
    { a: 2, b: 3, c: 4, d: 5, e: 1 },
    { a: 3, b: 4, c: 5, d: 1, e: 2 },
    { a: 4, b: 5, c: 1, d: 2, e: 3 },
    { a: 5, b: 1, c: 2, d: 3, e: 4 },
  ];

  return (
    <div style={{ width: "100%" }}>
      <Table tableLayout="fixed" columns={columns} dataSource={dataSource} />
    </div>
  );
}```
发布评论

评论列表(0)

  1. 暂无评论