Skip to content

唯一键

TIP

虚拟列表模式下记得指定 rowKey

props类型默认值描述
rowKeystring | (row:DataType) => string数组下标行唯一键
colKeystring | (col:StkTableColumn) => stringStkTableColumn['dataIndex']列唯一键
vue
<StkTable row-key="id"></StkTable>
<StkTable :row-key="row => row.code + row.type"></StkTable>

列唯一键 colKey

默认情况下列唯一键为 StkTableColumn['dataIndex'],当 dataIndex 相同的时候,需要指定 colKey

如果你想要配置相同dataIndex 的多列,这时候就需要使用 colKey 来指定列的唯一键,否则在虚拟列表模式下会出现渲染问题。

列配置里有可选参数,StkTableColumns['key'] 用于处理dataIndex 相同情况下的唯一键。

WARNING

出于向下兼容考虑,目前版本默认是不生效的。只有重写了 props.colKey 才生效。如下

vue
<StkTable :colKey="col => col.key || col.dataIndex"></StkTable>

根据 MIT 许可证发布