Sweetalert加载屏幕之前.withsucceshandler



我正在整合sweetalert2在我的谷歌工作空间插件。代码很简单。

成功和错误函数。

<script>
function swalsuccess() {
Swal.fire({
title: '¡Hecho!',
text: 'El script se ha ejecutado 👍',
icon: 'success',
confirmButtonText: 'Continuar'
})
}
</script>
<script>
function swalerror() {
Swal.fire({
title: 'Error!',
text: 'El script no ha podido ejecutarse.',
icon: 'error',
confirmButtonText: 'Entendido'
})
}
</script>

和一个执行onclick函数的按钮,带有" withsucceshandler "one_answers";withfailurehandler"显示脚本是否已应用于Google Sheet文档。

<button class="button-68" role="button" onclick="morphf354()">Eliminar filas (Max.k)</button>
<script>
function morphf354() {
google.script.run
.withSuccessHandler(swalsuccess)
.withFailureHandler(swalerror)
.deleteRows();
}
</script>

嗯,脚本需要几秒钟来实现这个功能,所以我想添加一个加载小屏幕,当它完成时,它会改变为swalsuccess。我不知道如何实现它,我不知道如何将我的代码与我在互联网上看到的解决方案相匹配。

感谢
  • 在制作google.script.run
  • 之前启动加载程序对话框
  • 在成功处理程序中关闭
function swalsuccess() {
Swal.close()
Swal.fire({
title: '¡Hecho!',
text: 'El script se ha ejecutado 👍',
icon: 'success',
confirmButtonText: 'Continuar'
})
}
function morphf354() {
Swal.fire({
titleText: "Checking data...",
allowOutsideClick: false,
preConfirm: Swal.showLoading,
showLoaderOnConfirm: true,
})
google.script.run
.withSuccessHandler(swalsuccess)
.withFailureHandler(swalerror)
.deleteRows();
}

设置Swal点火时间间隔

function swalsuccess() {
let timerInterval
Swal.fire({
title: '¡Hecho!',
text: 'El script se ha ejecutado 👍',
icon: 'success',
confirmButtonText: 'Continuar'
timer: 4000,
timerProgressBar: true,
didOpen: () => {
Swal.showLoading()
timerInterval = setInterval(() => {
const content = Swal.getHtmlContainer()
if (content) {
const b = content.querySelector('b')
if (b) {
b.textContent = Swal.getTimerLeft()
}
}
}, 100)
},
willClose: () => {
clearInterval(timerInterval)
}
}).then((result) => {
if (result.dismiss === Swal.DismissReason.timer) {
}
})

相关内容

  • 没有找到相关文章

最新更新