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

 

posted @ 2020-04-03 20:48  CEO雷总  阅读(25047)  评论(0)    收藏  举报