SweetAlert2:真的没有办法在单击按钮之前停止JS代码吗?

问题描述 投票:0回答:1

[建议在Swal Github中向SweetAlert2提问,因此我在这里发帖...

[我的(asp.net核心)应用程序中的保存按钮后面,我检查了一些事情-在某些情况下-必须询问用户(是/否),并且-根据他的选择-必须覆盖 before存储一些数据。

如果我使用(jQuery)警报或确认,代码将停止,直到用户单击按钮为止。在Swal中,我找不到任何方法(包括用“ .then(”)来stop代码),直到用户单击按钮为止。显示了该消息,但是代码运行得更远。...

是否真的可以[[not用Swal停止代码...?=>如果有办法,该怎么办...?

谢谢
javascript asp.net-core sweetalert2
1个回答
0
投票
它支持回调功能吗?这是我在examples中找到的一些代码。

Swal.fire({ title: 'Are you sure?', text: "You won't be able to revert this!", icon: 'warning', showCancelButton: true, allowOutsideClick: false, allowEscapeKey: false, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Yes, delete it!' }).then((result) => { if (result.value) { Swal.fire( 'Deleted!', 'Your file has been deleted.', 'success' ) } })

您可以根据result.value继续执行
© www.soinside.com 2019 - 2024. All rights reserved.