# Table-v2 虚拟化表格 🎉
在前端开发领域,表格一直都是一个高频出现的组件,尤其是在中后台和数据分析场景。 但是,对于 Table V1 来说,当一屏里超过 1000 条数据记录时,就会出现卡顿等性能问题,体验不是很好。
即使虚拟化的表格是高效的,但是当数据负载过大时,网络和内存容量也会成为您应用程序的瓶颈。 因此请牢记,虚拟化表格永远不是最完美的解决方案,请考虑数据分页、过滤器等优化方案。
TIP
该组件仍在 测试
中,生产环境使用可能有风险。 若您发现了 bug 或问题,请及时报告给我们以便修复。 同时,有一些 API 并未在此文档中提及,因为部分还没有开发完全,请联系开发者沟通。
# 代码演示
# API
# Table Attributes (继承 w-table 及 w-table-column 的属性)
参数 | 说明 | 类型 | 可选值 | 默认值 | Version |
---|---|---|---|---|---|
max-height | Table 的最大高度。合法的值为数字或者单位为 px 的高度。(虚拟列表是其值默认 500) | String/Number | - | ||
rowHeight | 每一行的高度 | Number | 40 | ||
size | 表格尺寸 | String | 'default' | ||
highlight-current-row | 是否要高亮当前行 | Boolean | — | false | |
table | 表格数据对象 | Object | {} | ||
---data | 展示数据 | Array | [] | ||
---operator | 表格内操作栏数据 | Array | [] | ||
-------render | render 函数渲染使用的 Function(val) 可以用 jsx 方式 | Function | - | ||
-------bind | 继承 w-button 所有 Attributes(默认值{ type:'text',size:'mini',}) | Object | - | ||
-------fun | 事件名 | function | - | ||
---operatorConfig | 表格内操作栏样式 | Object | {} | ||
--------fixed | 列是否固定在左侧或者右侧。 true 表示固定在左侧(true / 'left' / 'right') | string / boolean | - | ||
--------label | 显示的标题 | string | '操作' | ||
--------width | 对应列的宽度(固定的) | string / number | - | ||
--------minWidth | 对应列的最小宽度(会把剩余宽度按比例分配给设置了 min-width 的列) | string / number | - | ||
--------align | 对齐方式 (left / center / right) | string | 'left' | ||
--------bind | w-table-column Attributes | Object | - | ||
---firstColumn | 表格首列(序号 index,复选框 selection)排列 | object /Array | - | ||
-------type | selection/index/expand | String | - | ||
-------width | 表格首列宽度 | string / number | - | ||
-------fixed | 表格首列固定 | string/boolean | - | ||
-------label | 表格首列表头文字 | String | - | ||
-------bind | 继承 w-table-column 所有 Attributes | Object | - | ||
columns | 表头信息 | Array | [] | ||
----sortable | 排序 | Boolean | false | ||
----headerRequired | 是否显示表头必填'*' | Boolean | false | ||
----renderHeader | 列标题 Label 区域渲染使用的可以用 jsx 方式 | Function | - | ||
----bind | w-table-column Attributes | Object | - | ||
----width | 对应列的宽度(固定的) | string / number | - | ||
----minWidth | 对应列的最小宽度(会把剩余宽度按比例分配给设置了 min-width 的列) | string / number | - | ||
----render | 返回三个参数(text:当前值,row:当前整条数据 ,index:当前行) | function | - | ||
----slotName | 插槽显示此列数据(其值是具名作用域插槽) | String | - | ||
----------param/scope | 具名插槽获取此行数据必须用解构接收{param 或者 scope} | Object | 当前行数据 | ||
----slotNameMerge | 合并表头插槽显示此列数据(其值是具名作用域插槽) | String | - | ||
----------param/scope | 具名插槽获取此行数据必须用解构接收{param 或者 scope} | Object | 当前行数据 | ||
loading-text | 显示在加载图标下方的加载文案 | String | — | 数据加载中... | V2.4.28 |
loading | 是否加载中状态 | Boolean | — | false | V2.4.28 |
# Table Events 其他事件按照 w-table 直接使用(如 sort-change 排序事件)
事件名 | 说明 | 返回值 |
---|---|---|
sort-change | 当表格的排序条件发生变化的时候会触发该事件 | { column, prop, order } |
# Table Slots 插槽
插槽名 | 说明 | 参数 |
---|---|---|
expand | table.firstColumn.type:expand 展开行插槽 | scope |
- | w-table-column 某列自定义插槽(slotName 命名) | scope |
- | w-table-column 表头合并插槽(slotNameMerge 命名) | scope |
- | 操作列前一列自定义默认内容插槽 | - |