sweetalert 相关问题

SweetAlert是一个JavaScript库,它提供标准alert()对话的替代品。

使用 SweetAlert 或 SweetAlert2

任何人都可以建议我应该使用哪个 sweetalert 库以及为什么? 我正在编写一个 Node.js Web 应用程序,在对我可以使用哪些奇特的警报库进行一些研究后,我遇到了其中的两个......

回答 4 投票 0

SweetAlert:如何在文本中显示HTML代码?

我正在使用 SweetAlert 插件来显示警报。使用经典配置(默认),一切顺利。但是当我想在文本中添加 HTML 标签时,它显示 ... 而没有 ...

回答 12 投票 0

SweetAlert - 如何禁用初始打开时的自动对焦?

我正在使用 SweetAlert,并且我有像下面这样的示例的自定义按钮: swal("野生皮卡丘出现了!你想做什么?", { 纽扣: { 取消:“逃跑!”, 抓住: { 文字:“扔

回答 1 投票 0

如何在sweetalert2 insidehtml中渲染react组件?

这是我的代码,我想在 sweetalert 模式中渲染 CarReport 组件。 只是一个简单的形式。 Swal.火({ 标题: ”...” html: ...

回答 1 投票 0

使用 Sweet Alert 的 Toast 消息

我的吐司消息有问题。而不是在我填写表单提交后立即弹出 toast,即使我不提交表单提交,甚至我来自另一个页面,toast 仍然会出现...

回答 1 投票 0

如何在 ASP.NET 中使用 Sweet Alert 进行警报和重定向

ScriptManager.RegisterStartupScript(this, this.GetType(), “警报”, "alert('用户详细信息保存成功');window.location ='frmDisplayUsers.aspx';", 正确);

回答 3 投票 0

如何在SweetAlert2确认后执行PHP脚本?

我使用 Sweet Alert 2 来获得漂亮的对话框。 现在,我想用它来解决是否应删除数据库条目的安全问题。 显示对话没问题,但是我找不到方法

回答 1 投票 0

如何为PHP集成函数?

我使用 Sweet Alert 2 来获得漂亮的对话框。 现在,我想用它来解决是否应删除数据库条目的安全问题。 显示对话没问题,但是我找不到方法

回答 1 投票 0

是/否 - 如何为 PHP 集成函数?

我使用 Sweet Alert 2 来获得漂亮的对话框。 现在我想用它来回答安全问题是否应该删除数据库条目。 显示对话框没问题,但是我找不到整合的方法...

回答 1 投票 0

我的甜蜜警报隐藏在我的页面后面,我应该做什么甜蜜警报消息将隐藏我的页面而不是隐藏

当我点击表单中的提交按钮时,我必须弹出一个表单,甜蜜的警报会触发,但我看到它们隐藏在我的表单下,我希望它们不被隐藏,但我希望它们看起来像弹出的那样。 ..

回答 1 投票 0

使用 sweetalert 在我的网站中创建一个空白区域

我正在为一个学校项目制作这个表单,我添加了 JS Sweetalert,它工作正常,但它与我的 HTML 混淆。 这是 Sweetaletr 之前的网站 这是我使用 Sweetalert 之后的结果 它的工作原理是...

回答 1 投票 0

Laravel Sweet Alert 如何在会话中存储警报并在成功时显示它

我正在使用 RealRashid 的 Sweet Alert,我需要当用户创建类别时将他重定向到索引页面并发出警报成功消息 存储功能 公共函数存储(请求$请求)...

回答 1 投票 0

Sweetalert 在 Google 跟踪代码管理器中工作吗?

我一直在将代码从 Sweetalert 复制并粘贴到 Google 跟踪代码管理器中。它不会出现在预览中,并且在提交到网站后也不会出现。 Sweetlart 在 Google 跟踪代码管理器中工作吗...

回答 2 投票 0

带有表单 JS 的甜蜜提醒(3 个输入)

我想在甜蜜警报中实现一个表单。我可以只在里面放一个输入,包括标题和正文。 有一种方法可以自定义警报,文档说,但不允许加载 cl...

回答 3 投票 0

点击甜蜜警报上的“确定”按钮后如何重定向页面?

我可以在页面刷新后显示甜蜜警报,但我必须单击“确定”按钮,我收到甜蜜警报才能重定向页面。请帮助我。 我能够在页面刷新后显示甜蜜警报,但我必须单击“确定”按钮,我收到甜蜜警报才能重定向页面。请帮助我。 <?php echo '<script type="text/javascript">'; echo 'setTimeout(function () { swal("WOW!","Message!","success");'; echo '}, 1000);' echo 'window.location.href = "index.php";'; echo '</script>'; ?> 只需使用 JavaScript Promise。将 then 方法放在 swal 函数之后。我们不需要需要使用计时器功能。 例如: swal({ title: "Wow!", text: "Message!", type: "success" }).then(function() { window.location = "redirectURL"; }); promise方法.then用于等待用户读取模态窗口的信息,然后通过单击按钮来决定做出哪个决定。例如,Yes 或 No。 单击后,Sweet Alert 可以将用户重定向到另一个屏幕,调用另一个包含新问题和后续问题的 Sweet Alert 模式窗口,转到外部链接等。 再次强调,我们不必使用计时器,因为它可以更好地控制用户操作。用户可以等待永恒,也可以像灭霸或钢铁侠打响指一样采取行动。 😜 使用 Promise,代码变得更短、干净、优雅。 😉 要指定回调函数,您必须使用对象作为第一个参数,回调函数作为第二个参数。 echo '<script> setTimeout(function() { swal({ title: "Wow!", text: "Message!", type: "success" }, function() { window.location = "redirectURL"; }); }, 1000); </script>'; 您可以使用 timer 内置函数,即: swal({ title: "Success!", text: "Redirecting in 2 seconds.", type: "success", timer: 2000, showConfirmButton: false }, function(){ window.location.href = "//this-person-does-not-exist.com"; }); <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert-dev.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css"> 最佳且简单的解决方案,我们还可以添加更多事件! swal({ title: "WOW!", text: "Message!", type: "success"}).then(okay => { if (okay) { window.location.href = "URL"; } }); 我无法使用任何 swal(sweatAlert) 默认回调函数来做到这一点,所以我强制使用 jquery,让 Ok 按钮类检查 chrome 中的元素,并做了如下的操作: <script> sweetAlert({ title:'Warning!', text: 'Invalid user or password!', type:'warning' },function(isConfirm){ alert('ok'); }); $('.swal2-confirm').click(function(){ window.location.href = 'index.php'; }); </script> 函数(isConfirm)中的“Ok”警报只是一个测试,看看它是否会进入这个函数,如果是这样,我应该能够从那里重定向,但我没有...... 所以我使用 jQuery 来确定 swal 的按钮“OK”是否被点击,通过获取它的类:“.swal2-confirm”然后我可以成功重定向...... 希望对大家有帮助! PS:我使用 php echo 来运行脚本,我不必离开 php 来运行它,只需使用单引号即可完成! 如果有人需要帮助,此代码有效! swal({ title: 'Request Delivered', text: 'You can continue with your search.', type: 'success' }).then(function() { window.location.href = "index2.php"; }) Swal.fire({ title: result.value.title, icon: result.value.icon, text: result.value.message, }).then(function() { window.location.href = "url"; }) 以上解决方案都不适合我,我不得不使用.then swal({ title: 'Success!', text: message, type: 'success', confirmButtonText: 'OK' }).then(() => { console.log('triggered redirect here'); }); 我认为这会有所帮助。与 Barmer 先生给出的相同。但我已将其包含在 php 标签中。 就这样...... <?php if(!empty($_GET['submitted'])):?> <script> setTimeout(function() { swal({ title: "Congratulaions!", text: "Signed up successfully, now verify your mail", type: "success", confirmButtonText: "Ok" }, function() { window.location = "index.php"; }, 1000); }); </script> <?php endif;?> function confirmDetete(ctl, event) { debugger; event.preventDefault(); var defaultAction = $(ctl).prop("href"); swal({ title: "Are you sure?", text: "You will be able to add it back again!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, delete it!", cancelButtonText: "Cancel", closeOnConfirm: false, closeOnCancel: false }, function (isConfirm) { if (isConfirm) { $.get(ctl); swal({ title: "success", text: "Deleted", confirmButtonText: "ok", allowOutsideClick: "true" }, function () { window.location.href = ctl }) // $("#signupform").submit(); } else { swal("Cancelled", "Is safe :)", "success"); } }); } 现有的答案对我不起作用,我只是使用了$('.confirm').hide()。这对我有用。 success: function(res) { $('.confirm').hide() swal("Deleted!", "Successfully deleted", "success") setTimeout(function(){ window.location = res.redirect_url; },700); 我使用这段代码做到了: <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.js"></script> <script> $(".confirm").on('click',function(){ window.location.href = "index.php"; }); </script> 谢谢。 setTimeout(function(){ Swal.fire({ title: '<span style="color:#fff">Kindly click the link below</span>', width: 600, showConfirmButton: true, confirmButtonColor: '#ec008c', confirmButtonText:'<span onclick="my2()">Register</span>', padding: '3em', timer: 10000, background: '#fff url(bg.jpg)', backdrop: ` rgba(0,0,123,0.4) center left no-repeat ` }) }, 1500); } function my2() { window.location.href = "https://www.url.com/"; } 为我工作!! <head> <script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script> </head> <?php echo "<script> Swal.fire({ title: 'Do you want to save the changes?', showCancelButton: true, confirmButtonText: `Save`, denyButtonText: `Don't save`, }).then((result) => { if (result.isConfirmed) { window.location = 'www.google.com'; } else if (result.isDenied) { Swal.fire('Changes are not saved', '', 'info') } }) </script>"; ?> 您可以使用SweetAlert2中的回调函数,它对我有用。 swal({ title: "Success!", text: "Example success message", type: "success" }, function() { window.location.href = 'https://some-url'; }); $('.delete-record').on('click', function (e) { e.preventDefault(); window.url = $(this).attr('href'); swal({ title: 'Are you sure?', text: "You won't be able to revert this!", type: 'warning', showCancelButton: true, confirmButtonText: 'Confirm', padding: '2em' }).then(function (result) { if (result.value) { console.log(window.url); window.location.href = window.url; } }); }); swal("Payment send successfully", "Thanks for using Npay!", "success") .then(function() { router.push("/") }); Swal.fire({ icon: 'success', title: 'Sukses', text: 'Password berhasil diset!', timer: 5000, showConfirmButton: true, }).then((result) => { if (result.isConfirmed) { window.location.href = '/login'; } }); setTimeout(() => { window.location.href = '/login'; }, 5000); 这是React.js Vue.js的版本,5秒后它会自动转到你要去的页面

回答 18 投票 0

Sweetalert 2 图标问题

有人可以帮助我吗? 我尝试在我的应用程序上使用 sweetalert2,但如果使用“问题”、“警告”和“信息”,则这是不正确的。 来源:https://sweetalert2.github.io/

回答 5 投票 0

如何正确使用sweetalert / swal?

我是 Javascript / jQuery 新手。我想使用“sweetalert”库显示一些警报消息,并且根据用户响应,该函数将返回或继续。 这是我的实现:

回答 2 投票 0

在 React 中使用 SweetAlert 2 的组件作为 html

如何在带有 SweetAlert2 的 ReactJs 中使用组件作为 html 主体?我在点击事件上调用 swal 。 斯瓦尔({ 标题:“标题”, html: }); 我无法使用

回答 1 投票 0

我有一个带有 2 个按钮的表单,用于提交两个不同的表单操作和表单方法

我有两个按钮: 提交更改照片的表格并 一删除。 通过删除,我想将删除方法发送到带有甜蜜警报的路线删除。 然而这不起作用。 怎么...

回答 1 投票 0

sweetalert 2 中的输入不可输入或无法在materializecss 模式中输入

我有一个模式,当我点击添加账单按钮时,它会弹出sweetalert2,下面提供的代码来自他们的文档,所以我认为代码没有问题,无论如何,我的

回答 6 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.