简体   繁体   English

使用 SweetAlert 或 SweetAlert2

[英]Use SweetAlert or SweetAlert2

Can anyone advise on which sweetalert library I should use and why?谁能建议我应该使用哪个 sweetalert 库以及为什么?

I'm writing up a node.js web-app and upon doing some research on which fancy alert libraries I can use, I came across two of them that look the same: SweetAlert and SweetAlert2 .我正在编写一个 node.js 网络应用程序,在对我可以使用哪些花哨的警报库进行一些研究后,我发现其中两个看起来相同: SweetAlertSweetAlert2

You should use SweetAlert2 as it's updated regularly .您应该使用SweetAlert2 ,因为它会定期更新

From the creator of SweetAlert2 :来自 SweetAlert2 的创建者

The SweetAlert repo seems to be unmaintained. SweetAlert repo 似乎没有维护。 There's a bunch of Pull Requests without any replies, the last merged pull request was on Nov 9, 2014.有一堆 Pull Requests 没有任何回复,最后一个合并的 pull request 是在 2014 年 11 月 9 日。

I created SweetAlert2 with HTML support in modal and some other options for customization modal window - width, padding, Esc button behavior, etc.我创建了 SweetAlert2,在模态中支持 HTML 以及用于自定义模态 window 的其他一些选项 - 宽度、填充、Esc 按钮行为等。

TLDR: The original SweetAlert hasn't been updated since Apr 29 2019 , and has ignored many recent pull requests . TLDR:最初的 SweetAlert 自2019 年 4 月 29 日以来一直没有更新,并且忽略了许多最近的拉取请求 The creator of the new SweetAlert2 stated they wanted to add some new features so that's why they created SweetAlerts2.新 SweetAlert2 的创建者表示他们想要添加一些新功能,因此他们创建了 SweetAlerts2。

SweetAlert2 is simply a cleaner version. SweetAlert2 只是一个更简洁的版本。 The functions are much easier to use and the documentation provides much more usability, when compared to it's first version.与第一个版本相比,这些功能更易于使用,并且文档提供了更多的可用性。

As noted in the documentation, triggering the Swal in version 2 uses Swal.fire instead of Swal如文档中所述,在版本 2 中触发 Swal 使用Swal.fire而不是Swal

Swal.fire(
  'Good job!',
  'You clicked the button!',
  'success'
)

Otherwise, there are many other customised ways to style each alert: https://sweetalert2.github.io/否则,还有许多其他自定义方式来设置每个警报的样式: https://sweetalert2.github.io/

Upon going through the sweetalert upgrade logs, it is recommended to use sweetalert2 because of its easy to use, flexible, awesome new changes.翻阅 sweetalert 升级日志后,推荐使用 sweetalert2,因为它易于使用、灵活、令人敬畏的新变化。

You can have a read from this link: sweetalert upgrade logs您可以从此链接阅读: sweetalert upgrade logs

Go ahead and use SweetAlert2 . Go 提前并使用SweetAlert2

It comes with alot of functionalities and is regularly updated.它具有很多功能,并且会定期更新。

It looks like the initial SweetAlert library has not been updated for some time now.看起来最初的 SweetAlert 库已经有一段时间没有更新了。 Their NPM package shows that it was last published 3 years ago.他们的NPM package表明它最后一次发布是在 3 年前。

Also check out this answer for more info: answer另请查看此答案以获取更多信息: 答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM