【问题标题】:How to add a confirm button handler如何添加确认按钮处理程序
【发布时间】:2022-01-04 00:18:59
【问题描述】:

有没有办法给确认按钮添加一个处理程序(这样我可以在用户点击确认时清除错误消息):

{ magic.errorMessage && <SweetAlert
              title="Error"
              show={true}
              html={magic.errorMessage}
              type="error"
              showCancelButton={false}
              showConfirmButton={true}
              onClick={() => { console.log("YES YES YES") }}
              
            />
          }````

【问题讨论】:

  • 作为记录,我最初使用的是show={magic.errorMessage},但这导致反应 dom 渲染问题

标签: sweetalert2


【解决方案1】:
<SweetAlert
              title="Error"
              show={!magic.entity?.loggedIn && magic.errorMessage}
              html={magic.errorMessage}
              type="error"
              showCancelButton={false}
              showConfirmButton={true}
              onConfirm={() => clearError()}
            />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-01
    • 2013-05-06
    • 1970-01-01
    • 1970-01-01
    • 2015-02-26
    • 1970-01-01
    • 2010-12-13
    • 2017-02-28
    相关资源
    最近更新 更多