html - Swal 显示加载属性 HTML
问题描述
我正在使用 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()
}
})
}
解决方案
您可以使用甜蜜警报中提供的 html 描述并在其中显示加载 gif。
Swal.fire({
title: 'Auto close alert!',
timer: 3000,
html:
'<img src="https://media.giphy.com/media/xTk9ZvMnbIiIew7IpW/giphy.gif">'
})
推荐阅读
- r - 使用 Baseflow 包的时间序列 R 中向量长度的不合理错误
- reactjs - 与 jest/RTL 测试中的常规文档查询选择器找到的页面元素交互
- mysql - id IN(其他 id 的列表)取决于 IF
- artifactory - conda-forge / cran 包装的 X 射线扫描
- algorithm - 在多级排序链表中插入和删除
- javascript - 希望从文本输入中获取 Quantity 并使用 OnClick="location.href" 将信息推送到新页面
- flutter - 使用 Switch 时的 showModalBottomSheet 堆叠
- google-apps-script - 使用 Google Apps 脚本从多个表单中获取回复并向每个回复者发送一次电子邮件
- python - 如何让 APScheduler 运行 python 脚本?
- sql - Excel 电源查询(使用 SQL)将行值作为参数传递