表格数据从后台拉的,有一个删除按钮,我这样处理才能点击删除的时候向后台发该行的ID,然后完成删除操作呢
function deleteArticle(Id) {
console.log(Id);
};
const columns = [{
title: '标题',
dataIndex: 'title',
width: '30%',
}, {
title: '作者',
dataIndex: 'author',
width: '20%',
}, {
title: '文章收藏数量',
dataIndex: 'collect_count',
},{
title: '创建时间',
dataIndex: 'time_created',
render: time_created => `${getLocalTime(time_created)}`,
},{
title: '更新时间',
dataIndex: 'time_updated',
render: time_updated => `${getLocalTime(time_updated)}`,
},{
title: '操作',
render: (text, record, index) => {
//获取该行的id,可以获取的到,传到函数里的时候打印直接把整个表格所有行id全部打印了
const Id = record.id;
return (
<Popconfirm title="确定删除?" onConfirm={deleteArticle(Id)}>
<a href="#">删除</a>
</Popconfirm>
);
}
}];
现在我的这种做法是错误的,求大神指点正确的写法。
<Popconfirm title="确定删除?" onConfirm={() => deleteArticle(Id)}>