•  提示框插件有很多,不同的框架中选择的也不一样。
  • 本文主要分享toastr插件
  • 总结它的使用步骤如下:

使用步骤:

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

  2. 全局配置。为方便,我们将下面的配置放到 assets/utils/toastr.js 中,使用时,加载这个配置文件即可

toastr.options = {
  // "closeButton": false,
  // "debug": false,
  // "newestOnTop": false,
  // "progressBar": false,
  "positionClass": "toast-top-right", // 提示框位置,这里填类名
  // "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('提示信息');               // 错误提示

实操示范:

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐