antd Table 拖拽 调整列宽

编程入门 行业动态 更新时间:2024-10-07 14:29:57

antd Table <a href=https://www.elefans.com/category/jswz/34/1765858.html style=拖拽 调整列宽"/>

antd Table 拖拽 调整列宽

1. 先看 拖拽效果

2. 开发实现

安装依赖 yarn add @minko-fe/use-antd-resizable-header

 "@minko-fe/use-antd-resizable-header": "^2.5.0"

引入库 方法+样式

import { useAntdResizableHeader } from '@minko-fe/use-antd-resizable-header';
import '@minko-fe/use-antd-resizable-header/dist/style.css';

利用 useAntdResizableHeader 获取 columns 的 resizableColumns components tableWidth

const columns = [];const { resizableColumns, components, tableWidth } = useAntdResizableHeader({columns: useMemo(() => columns, []),
});

Table or ProTable 添加主要 attribute columns components scroll

<Table
columns={resizableColumns}
components={components}
scroll={{ x: tableWidth }}/>or<ProTablecolumns={resizableColumns}components={components}scroll={{ x: tableWidth }}/>

3. 注意

columns 不能全设置 width 否则不能进行拖拽

4. 其他说明 link

两种方法

更多推荐

antd Table 拖拽 调整列宽

本文发布于:2024-02-07 10:38:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1756723.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:拖拽   antd   Table

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!