在 toastr 中使用超时

Mer*_*lin 2 javascript timeout toastr

大多数 toastr 演示仅限客户端。

如果我得到这个 json 数据的服务器推送

   [
    {"msg": "Mortgage bill paid", "t": "i"}
    {"msg": "Account Balance below $3000", "t": "i"}
    {"msg": "Received Car payment request", "t": "w"}
    ]
Run Code Online (Sandbox Code Playgroud)

我将如何使用 toastr 阅读项目并发布 1 和 2 的“信息”,3 的“警告”,右下角可以。我想在吐司之间延迟 2000 次,这样吐司就不会同时到来。

你能指出我的例子,显示类似的东西。toastr 可以做到这一点。从某种意义上说,定时消息传递。

Haf*_*ani 8

我猜这正是你需要的东西

setTimeout((function() {
   toastr.info('MESSAGE TITLE', 'message content', {options});
}), delay);

toastr.options = {
  "closeButton": true,
  "debug": false,
  "newestOnTop": false,
  "progressBar": false,
  "positionClass": "toast-top-center",
  "preventDuplicates": false,
  "onclick": null,
  "showDuration": "300",
  "hideDuration": "1000",
  "timeOut": "5000",
  "extendedTimeOut": "1000",
  "showEasing": "swing",
  "hideEasing": "linear",
  "showMethod": "fadeIn",
  "hideMethod": "fadeOut"
}
Run Code Online (Sandbox Code Playgroud)