https://juejin.cn/post/6963086046720425992#heading-3
https://juejin.cn/post/6882703111710834701
https://www.jianshu.com/p/39404c94dbd0
https://juejin.cn/post/6844903982742110216
https://github.com/wubostc/virtualized-table-for-antd
https://codesandbox.io/s/tianjiahuanchongqu-vlxg2
https://codesandbox.io/s/jinyongshubiaoshijian-554tw
https://codesandbox.io/s/xiugaihuanchongqushezhi-z3t08
https://clauderic.github.io/react-tiny-virtual-list/#/controlled-props/controlled-scroll-offset?_k=87jwx1
https://codesandbox.io/s/kymm7z9qr
https://developers.google.com/web/updates/2016/07/infinite-scroller
https://github.com/clauderic/react-tiny-virtual-list
https://github.com/ctq123/ant-virtual-table
https://codesandbox.io/s/antdxunibiao-demo-rj5qc?file=/index.js
https://github.com/crawler-django/virtuallist-antd
https://ixkaito.github.io/stickyTableColumns/
https://github.com/ixkaito/stickyTableColumns
https://codesandbox.io/s/drag-row-1fjg4?file=/index.js
https://turnerniles.github.io/react-virtualized-pivot/
https://github.com/turnerniles/react-virtualized-pivot
columns 设置width无效
设置 scroll的width等于所有列宽之和 scroll={{ x: 100%}})
- x: 100% 无效
- x: 等于父级宽度,也无效
- 当td里的内容超出了width的范围时,会出现width不固定,也就是width不生效 ```jsx const columns = [ { title: ‘姓名’, dataIndex: ‘name’, width: 100 }, // … 100 item ];
<a name="r3ycs"></a>## 文本超出隐藏table是一个整体,每一列td的宽度是由一个其中一个最长td的宽度决定的```less.table {word-wrap:bread-word;word-break:break-all;table-layout:fixed}
在 3.24.0 之前,你需要针对超长字段的列增加折断样式
- 最好的解决方案可能还是不默认 break word,提供一个属性来针对某些列进行断行处理
- 超长连续字段(长数字和长单词) 破坏表格布局的问题,即使你指定了列的宽度也会被挤开 ```jsx columns={[ // … textWrap: ‘word-break’, ]}
columns={[ // … render: (text, record) => (
<a name="vI7hS"></a>### antd4.x ellipsis4.x 设置 column.ellipsis 可以让单元格内容根据宽度自动省略<br />设置 column.ellipsis.showTitle 关闭单元格内容自动省略后默认的 title 提示, 使用 Tooltip 替代<br />[https://ant.design/components/table-cn/#API](https://ant.design/components/table-cn/#API)```jsximport { Table, Tooltip } from 'antd';const columns = [{title: 'Name',dataIndex: 'name',key: 'name',render: text => <a>{text}</a>,width: 150,},{title: 'Long Column Long Column Long Column',dataIndex: 'address',key: 'address',ellipsis: true,},{title: 'Long Column Long Column Long Column',dataIndex: 'address',key: 'address 2',ellipsis: {showTitle: false,},render: address => (<Tooltip placement="topLeft" title={address}>{address}</Tooltip>),},];
Select超出隐藏
<Selectstyle={{ width: 100 }}>{dataSource.map(({ title, id }) => {const width = getTextWidth(title);return (<Select.Option key={id} value={title}><Tooltip title={width > 100 ? title : null}><span className="ellipsis" style={{ width: 100 }}>{title}</span></Tooltip></Select.Option>);})}</Select>
动态计算页面可视区剩余高度
Table 小屏下会出现两条滚动个,页面自身一个,table一个
- calc(100vh - 导航条的高度 - 面包屑的高度)
- 需要 addEventListener(‘resize’) ```jsx // 页面总视图高度 document.body.clientHeight
document.documentElement.clientHeight
<a name="VEZbH"></a>## td列内滚动在columns中设置了列的宽度,设置最大高度- 内容超出该高度会出现滚动条高度,overflow-y: scroll 溢出滚动就可以- 滚动条样式为浏览器自带的- 可以通过 [css来美化滚动条样式](https://www.yuque.com/lulongwen/web/gmz4wk)```jsx{title: '评价内容',dataIndex: 'comment',width: 120,render: (text) => <div className={styled.scroll}>{text}</div>}
less
.scroll {height: 90px;// overflow-y: scroll;overflow-y: auto;}
https://blog.csdn.net/sillies_3/article/details/102833859
可滑动表格组件
https://blog.csdn.net/weixin_45416217/article/details/104791095
https://segmentfault.com/q/1010000016507297/a-1020000016507798
自定义滚动条
https://blog.csdn.net/sillies_3/article/details/102833859
滚动加载数据https://blog.csdn.net/abc2346789/article/details/101188416
要把 .ant-table-body的 overflow 设置为 hidden,否则会显示默认的 滚动条区域。
import React, { useEffect, useRef } from 'react';import { Table } from 'antd';import { Scrollbars } from 'react-custom-scrollbars';// 数据表头const columns = [{title: '姓名',dataIndex: 'name',key: 'name',},{title: '年龄',dataIndex: 'age',key: 'age',},{title: '住址',dataIndex: 'address',key: 'address',},];const dataSource = [{key: '1',name: '胡彦斌',age: 32,address: '西湖区湖底公园1号',},{key: '2',name: '胡彦祖',age: 42,address: '西湖区湖底公园1号',},{key: '3',name: '胡彦祖',age: 42,address: '西湖区湖底公园1号',},{key: '4',name: '胡彦祖',age: 42,address: '西湖区湖底公园1号',},{key: '5',name: '胡彦祖',age: 42,address: '西湖区湖底公园1号',},{key: '6',name: '胡彦祖',age: 42,address: '西湖区湖底公园1号',},// 增加空白列 {}];// 滚动条参数const scroll = {// 如果最终结果表格内容与表格头部无法对齐,表格头需要增加空白列,弹性布局width: '100%',// 最大高度,内容超出该高度会出现滚动条height: 100,};function ScrollTable() {const tableRef = useRef();useEffect(() => {// 覆盖 ant table 自带滚动条样式const el = tableRef.current.container.parentNodeel.style.overflow = 'hidden';}, []);// 滚动结束,记下滚动位置function handleScrollStop() {if (!tableRef.current) return;tableRef.current.getScrollTop();}// 用 react-custom-scrollbars包裹住表格内容const components = {table(props) {const { className, children } = props;return (<Scrollbarsstyle={scroll}onScrollStop={handleScrollStop}ref={tableRef}><table className={className}>{children}</table></Scrollbars>);},};return (<TabledataSource={dataSource}columns={columns}// scroll选项必须开启,宽高与react-custom-scrollbars插件一致scroll={{ y: scroll.height, x: scroll.width }}// 将 react-custom-scrollbars组件插入到表格中components={components}/>);}export default ScrollTable;

