"Ant Design Row Selection 点击回调:onSelect 和 onSelectAll 使用指南"\n\nAnt Design 的 rowSelection 组件的 selection 选择项点击回调可以通过 onSelect 或 onSelectAll 属性来实现。\n\nonSelect 属性是当用户手动选择 / 取消选择某行时触发的回调函数。它接收选中的行的 key 和当前选中的行数组作为参数。示例代码如下:\n\njsx\nimport { Table } from \'antd\';\n\nconst rowSelection = {\n onSelect: (record, selected, selectedRows) => {\n console.log(record, selected, selectedRows);\n },\n};\n\nconst YourComponent = () => (\n <Table rowSelection={rowSelection} dataSource={data} columns={columns} />\n);\n\n\nonSelectAll 属性是当用户手动选择 / 取消选择所有行时触发的回调函数。它接收是否全选和选中的行数组作为参数。示例代码如下:\n\njsx\nimport { Table } from \'antd\';\n\nconst rowSelection = {\n onSelectAll: (selected, selectedRows) => {\n console.log(selected, selectedRows);\n },\n};\n\nconst YourComponent = () => (\n <Table rowSelection={rowSelection} dataSource={data} columns={columns} />\n);\n\n\n以上是两种常用的选择项点击回调的实现方式,你可以根据具体需求选择适合的方式来处理选择项的点击事件。


原文地址: http://www.cveoy.top/t/topic/qapX 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录