AntD Modal.confirm 确认弹出框用法

<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
})
});
};

猜你喜欢

转载自www.cnblogs.com/gslgb/p/12628867.html