簡體   English   中英

在Toastr中使用超時

[英]Using timeouts with toastr

大多數烤面包機演示僅在客戶端。

如果我收到此json數據的服務器推送

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

我將如何使用Toastr通讀項目並為1和2發布“信息”,為3,右下角發出“警告”。 我希望在兩次吐司之間延遲2000年,以便不要同時吐司。

您能指出一些類似的例子嗎? 敬酒可以做到這一點。 從某種意義上說,定時消息傳遞。

您可以遍歷數組並調用toastr ['info']或toastr ['warning'](例如,將i映射到info)。 對於延遲,您可以使用超時並將每個消息延遲2000 ms。

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

我猜這正是您需要的東西

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