要在Antd Table的单元格中实现内容上下居中,可以使用CSS样式来实现。首先,给表格单元格的类名添加一个样式:

.cell-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

然后,在Table组件的columns中的对应列的render方法中,给单元格的className属性添加该样式类名:

const columns = [
  {
    title: 'Name',
    dataIndex: 'name',
    key: 'name',
    render: (text) => <div className="cell-center">{text}</div>,
  },
  // 其他列...
];

这样,单元格中的内容就会上下居中显示了。

antd table 单元格内容上下居中

原文地址: http://www.cveoy.top/t/topic/iHdK 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录