Bootstrap 5 Toast & Snackbar Manager jQuery Toast.js

  • 源码大小:9.76KB
  • 所需积分:1积分
  • 源码编号:19JP-3669
  • 浏览次数:687次
  • 最后更新:2023年07月09日
  • 所属栏目:其他
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

这是Script47的jQuery Toast插件的升级版,可以帮助您在全新的Bootstrap 5框架中生成Android风格的小吃和烤面包。

如何使用它:

1.在Bootstrap 5项目中加载最新的jQuery库(slim build)和Bootstrap 5toast插件。

  1. <!-- Bootstrap 5 -->
  2. <link rel="stylesheet" href="/path/to/cdn/bootstrap.min.css" />
  3. <script src="/path/to/cdn/bootstrap.bundle.min.js"></script>
  4. <!-- jQuery -->
  5. <script src="/path/to/cdn/jquery.slim.min.js"></script>
  6. <!-- Bootstrap 5 Toast -->
  7. <script src="/path/to/dist/toast.min.js"></script>

2.使用点心方法

  1. // $.snack(type, content, delay)
  2. // type: 'info', 'warning', 'success', 'error'
  3.  
  4. // always shown
  5. $.snack('info', 'Snackbar');
  6.  
  7. // auto dimiss after 3 seconds
  8. $.snack('info', 'Snackbar', 3000);

3.使用干杯方法

  1. $.toast({
  2. type: 'info',
  3. title: 'Title',
  4. subtitle: '11 mins ago',
  5. content: 'Toast message.',
  6. delay: 5000,
  7. img: {
  8. src: '/path/to/img.',
  9. class: 'yourClass',
  10. alt: 'Image Alt'
  11. }
  12. });

4.通过覆盖默认参数来配置烤面包和小吃条:

  1. $.toastDefaults = {
  2.  
  3. // top-left, top-right, bottom-left, bottom-right, top-center, and bottom-center
  4. position: 'top-right',
  5.  
  6. // is dismissable?
  7. dismissible: true,
  8.  
  9. // is stackable?
  10. stackable: true,
  11.  
  12. // pause delay on hover
  13. pauseDelayOnHover: true,
  14.  
  15. // additional CSS Classes
  16. style: {
  17. toast: '',
  18. info: '',
  19. success: '',
  20. warning: '',
  21. error: '',
  22. }
  23. };

更新日志:

2022-03-17

  • 错误修复

预览截图