【问题标题】:Using timeouts with toastr在 toastr 中使用超时
【发布时间】:2013-11-10 00:22:11
【问题描述】:

大多数 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 年,这样吐司就不会同时出现。

您能否指出显示类似内容的示例。烤面包机可以做到这一点。某种意义上的定时消息传递。

【问题讨论】:

    标签: javascript timeout toastr


    【解决方案1】:

    我猜这正是你需要的东西

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

    【讨论】:

      【解决方案2】:

      您可以遍历数组并调用 toastr['info'] 或 toastr['warning'] (例如,将 i 映射到 info)。对于延迟,您可以使用超时并将每个消息延迟 2000 毫秒。

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

      【讨论】:

      • 我解决了...它的 setTimeout(...)..延迟到 JSON 表的权利。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-25
      相关资源
      最近更新 更多