<a className={"deleteProject"} onClick={() => this.showDeleteConfirm(record.id)}>刪除</a>
//按鈕的oClick事件調用此函數
showDeleteConfirm = (id) => {
Modal.confirm({
title: '確認刪除此項目嗎?',
icon: <ExclamationCircleOutlined/>,
content: '',
okText: '是',
okType: 'danger',
cancelText: '否',
onOk: () => {
this.handleOk(id)//確認按鈕的回調方法,在下面
}
,
onCancel() {
console.log('Cancel');
},
});
};
//刪除的彈出框的確認按鈕,執行刪除操作
handleOk = (id) => {
let params = {id: id};
fetchPost(global.constants.deleteProject【此處填寫自己后端接口url】, params).then(
res => this.setData(res)
).catch(e => console.log(e))
.finally(() => {
this.setState({
requestLoading: false
})
});
};