【发布时间】:2017-10-01 07:46:43
【问题描述】:
早安:
我正在尝试在 Laravel 中使用插件 Sweet Alert。 我的问题是,我不知道如何在控制器中放置带有取消按钮和确认按钮的警报。 看了文档,只发现了这句话:
Alert::warning('Are you sure?', 'message')->persistent('Close');
另外,我正在尝试:
echo '<script>swal({ title: "Are you sure?", text: "name is available, continue save?", type: "warning", showCancelButton: true, confirmButtonColor:"#DD6B55", confirmButtonText: "Yes, delete it!", closeOnConfirm: false }, function(){});</script>';
但它不起作用。
如何在显示取消按钮和确认按钮的控制器中使用 Sweet Alert?
谢谢
【问题讨论】:
-
嗨,你在使用这个 repo 吗? github.com/uxweb/sweet-alert
-
看起来他正在使用它。我个人认为图书馆创造了比必要更多的工作。像这样简单的东西; swal({ title: 'Are you sure?', text: '该产品将被添加。', type: 'info', showCancelButton: true, confirmButtonText: '是的,导入它!', cancelButtonText: '否,取消' }) 应该管用。只需包含 limonte.github.io/sweetalert2 脚本即可。
-
在你的 HTML 中包含 sweetalert2 脚本之后,你有没有在 Laravel 之外尝试过这个?可能没有包含脚本。
-
看来他正试图从控制器本身调用,因为他正在使用 echo 来实现这一点..
-
感谢您的回答。是的,我在 Laravel 5.4 中使用来自 Github 的 Sweet-Alert 我无法显示带有 de 代码的确认按钮给我文档。只能显示关闭按钮:->persistent('Close');我读到了一种在控制器中使用“echo”的方法。但是,我正在测试并且无法正常工作。
标签: php laravel sweetalert