提示框插件toastr

  • 提示框插件有很多,不同的框架中选择的也不一样。

  • 案例中,提示框使用的是 toastr 插件。(挂的是GitHub链接,可能打不开)

  • toastr文档

  • 总结它的使用步骤如下:

使用步骤:

  1. 加载 toastr.css 和 toastr.js 文件

  2. 全局配置。为方便,我们将下面的配置单独写个 toastr.js 作为全局配置,一般会放在utils(全局工具)文件夹中,使用时,加载这个配置文件即可

     toastr.options = {
       // "closeButton": false,
       // "debug": false,
       // "newestOnTop": false,
       // "progressBar": false,
       "positionClass": "toast-center-center", // 提示框位置,这里填类名
       // "preventDuplicates": false,
       // "onclick": null,
       "showDuration": "300",              // 提示框渐显所用时间
       "hideDuration": "300",              // 提示框隐藏渐隐时间
       "timeOut": "2000",                  // 提示框持续时间
       // "extendedTimeOut": "1000",
       // "showEasing": "swing",
       // "hideEasing": "linear",
       // "showMethod": "fadeIn",
       // "hideMethod": "fadeOut"
     }
  3. 调用方法,直接使用

     toastr.info('提示信息');                // 普通提示
     toastr.success('提示信息');             // 成功提示
     toastr.warning('提示信息');             // 警告提示
     toastr.error('提示信息');               // 错误提示

猜你喜欢

转载自blog.csdn.net/m0_55960697/article/details/124269726