【问题标题】:sweertAlert2 closing the pop calls onConfirm methodsweertAlert2 关闭 pop 调用 onConfirm 方法
【发布时间】:2019-04-11 11:19:51
【问题描述】:

我正在使用 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 参数,但是当我再次单击它时,会进行删除关键字调用。

有什么建议吗?

【问题讨论】:

    标签: reactjs sweetalert2 cancel-button


    【解决方案1】:

    我把方法改成onConfirm={(e) =&gt; {this.deleteKeyword(e)}}e告诉我是确认还是驳回。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多