试了几种方式
记录一下比较有效的一种
import { Button } from 'antd';
interface recordClass{
id: string,
name: string
}
const records = [];
const handleButtonClick = (id:string) => {
console.log(id);
}
export default () => {
return (
<div>
{records.map((record:recordClass,index) => (
<div>
<p>{record.name}</p>
<Button onClick={(e) => handleButtonClick(record.id)} >Button</Button>
</div>
))}
</div>
);
}