sweetAlert2关闭pop调用Confirm方法

问题描述 投票:1回答:1

我正在使用SweetAlert2来提醒用户。当我点击确认按钮时,行为符合预期,删除关键字调用。

render: function() {
return(
<SweetAlert show={this.state.show} title="Context Processor"
                 text="Keyword deletion cannot be undone. Do you still want to continue?"
                onConfirm={this.deleteKeyword}
                showCloseButton={true}
                heightAuto={false}>
                </SweetAlert>
)},

deleteKeyword: function() {
        this.setState({show: false});
        this.props.deleteKeyword(this.state.keyword);
    },

但是,当我只是关闭警报框时,再次拨打电话!我浏览了图书馆提供的各种选项 - https://github.com/kessejones/react-sweetalert2/blob/master/src/ReactSweetAlert2.js,但我找不到任何兴趣。此外,添加了showCloseButton参数,但当我点击它时,再次进行删除关键字调用。 enter image description here

有什么建议?

reactjs sweetalert2 cancel-button
1个回答
0
投票

我把方法改为onConfirm={(e) => {this.deleteKeyword(e)}} e告诉我它是否被证实或被驳回。

© www.soinside.com 2019 - 2024. All rights reserved.