【问题标题】:Sweetalert 2 more than 2 buttons. Don't close on denySweetalert 2 多于 2 个按钮。不要关闭拒绝
【发布时间】:2020-10-21 21:49:50
【问题描述】:

我正在使用this 答案中的示例在 swal 上显示不止 2 个按钮。 当用户单击拒绝按钮时,我想更改 swal 的 html 中的某些内容而不关闭它。现在,当单击拒绝按钮时,swal 将关闭。 我在哪里以及如何指定 swal 不应该关闭?

【问题讨论】:

    标签: sweetalert2


    【解决方案1】:

    我刚刚添加了preDeny 参数,它允许通过返回保持模式打开 false:

    Swal.fire({
      title: 'The "deny" button will not close me',
      showDenyButton: true,
      preDeny: () => {
        return false
      }
    })
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script> 

    阅读更多关于preDenyhttps://sweetalert2.github.io/#pre-deny

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-13
      • 2011-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多