简体   繁体   English

在Toastr中使用超时

[英]Using timeouts with toastr

Most of the toastr demos are client side only. 大多数烤面包机演示仅在客户端。

If I get a server push of this json data 如果我收到此json数据的服务器推送

   [
    {"msg": "Mortgage bill paid", "t": "i"}
    {"msg": "Account Balance below $3000", "t": "i"}
    {"msg": "Received Car payment request", "t": "w"}
    ]

How would I use toastr read through items and publish 'info' for 1 and 2, "warning" for 3, lower right is ok. 我将如何使用Toastr通读项目并为1和2发布“信息”,为3,右下角发出“警告”。 I would like a delay of 2000 between toasts so the toast dont come at the same time. 我希望在两次吐司之间延迟2000年,以便不要同时吐司。

Can you point me to example that show something similar. 您能指出一些类似的例子吗? Can toastr do this. 敬酒可以做到这一点。 Timed messaging in a sense. 从某种意义上说,定时消息传递。

You could loop through the array and call toastr['info'] or toastr['warning'] (map the i to info, for example). 您可以遍历数组并调用toastr ['info']或toastr ['warning'](例如,将i映射到info)。 FOr delays, you could use a timeout and delay the messages by 2000 ms for each. 对于延迟,您可以使用超时并将每个消息延迟2000 ms。

timeout(toastr['info']('your message'), 2000);

This is the exact thing you need I guess 我猜这正是您需要的东西

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"
}

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

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