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['key']作为列唯一键,如果key为空,则取 StkTableColumn['dataIndex']作为列唯一键。

如果您想要配置相同dataIndex 的多列,这时候就需要使用 key 字段来指定列的唯一键,key是可选字段,参考StkTableColumn 类型定义

ts
const columns:StkTableColumn[] = [
    { key: '1', dataIndex: 'a',title: 'A1' },
    { key: '2', dataIndex: 'a', title: 'A2' },
    { dataIndex: 'b', title: 'B' },
    { dataIndex: 'c', title: 'C' },
]

根据 MIT 许可证发布