react使用Ant Design 的table组件添加button按钮后,按钮怎么获取当前行数据

解决办法:

按钮的点击函数

 xiugai = (row) => () => {
    
    
        console.log(row)
    }

columns 的最后一项,按钮组件
在这里插入图片描述

{
    
    
                title: '操作',
                width: '100px',
                align: 'center',
                //这里传当前行的数据row,(自定义名称)
                render: (row) =>
                    <div>
                        {
    
    /* <Button style={
    
    { marginRight: '10px' }} danger>删除</Button> */}
                        {
    
    /*通过点击事件传递数据*/}
                        <Button type='primary' onClick={
    
    this.xiugai(row)}>修改</Button>
                    </div>
            }

页面获取到数据:
在这里插入图片描述
去试试吧~

猜你喜欢

转载自blog.csdn.net/qq_43690438/article/details/110441571