【问题标题】:Swal show loading property HTMLSwal 显示加载属性 HTML
【发布时间】:2019-11-21 10:32:29
【问题描述】:

我正在使用 SWAL2 (Sweet Alert2) 来显示警报,并且我想显示加载进度微调器,但对于 html,没有文档仅显示加载微调器。有一个属性showLoaderOnConfirm,它会在您单击确认按钮后显示加载微调器。我只想在显示警报时显示加载微调器,并通过 html 实现。

当您单击查找时,会发生这样的事情:https://sweetalert2.github.io/#ajax-request

<button mat-button type="button" [disabled]="paymentModeForm.get('endpoint').value == ''" (click)="testConn.show()" color="primary">
        <mat-icon matPrefix>power</mat-icon>
        <span i18n="@@testConnButton">Test Connection</span>
</button>
<swal #testConn title="Testing connection..." text="Checking the connection to {{paymentMode?.paymentMode}}" [showLoaderOnConfirm]="true"></swal>

使用 .TS 我可以做到:

  async testConnection(): Promise<void> {
    Swal.fire({
      title: 'Auto close alert!',
      timer: 3000,
      onBeforeOpen: () => {
        Swal.showLoading()
      }
    })
  }

文档:https://sweetalert2.github.io/#frameworks-integrations

【问题讨论】:

    标签: html angular sweetalert2 angular8


    【解决方案1】:

    您可以使用甜蜜警报中提供的 html 描述并在其中显示加载 gif。

    Swal.fire({
      title: 'Auto close alert!',
      timer: 3000,
      html:
        '<img src="https://media.giphy.com/media/xTk9ZvMnbIiIew7IpW/giphy.gif">'
      })
    

    【讨论】:

    • 这不是我想要的:-(
    • 这符合您对使用 html 显示加载程序的描述。您将不得不编辑您的问题,以便更清楚地了解您需要什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-16
    • 2012-06-10
    • 2015-01-07
    相关资源
    最近更新 更多