【问题标题】:Toastr JS Setting fadeAway valueToastr JS设置fadeAway值
【发布时间】:2013-01-15 21:53:32
【问题描述】:

我正在使用一个很酷的 alert js 库项目:https://github.com/CodeSeven/toastr

我想在一段时间后淡出下面的变化。 查看 toastr.js 文件,我确实看到了选项。 我只是不知道如何访问属性'fadeAway'

toastr.info('Processing...');

我试过了

toastr.info('Processing...', fadeAway:1000);

如何通过传入参数来使用fadeAway?

【问题讨论】:

    标签: javascript alert toastr


    【解决方案1】:

    在调用 toastr.info 之前,请设置您选择的选项。例如:

    toastr.options.fadeOut = 2500;
    

    您可以在此处看到演示中的许多选项:toastr demo

    这些是默认值。您可以覆盖其中的许多:

    options = {
      tapToDismiss: true,
      toastClass: 'toast',
      containerId: 'toast-container',
      debug: false,
      fadeIn: 300,
      fadeOut: 1000,
      extendedTimeOut: 1000,
      iconClass: 'toast-info',
      positionClass: 'toast-top-right',
      timeOut: 5000, // Set timeOut to 0 to make it sticky
      titleClass: 'toast-title',
      messageClass: 'toast-message'
    }
    

    【讨论】:

      【解决方案2】:

      您还可以在参数中传递任何选项。但是参数必须是一个对象。对于您的示例,您可以使用:

      toastr.info('Processing...', { fadeAway: 1000 });
      

      PS:还请记住,fadeAway 在当前版本 (2.0.3) 中已弃用。

      【讨论】:

        【解决方案3】:

        在 2.0.3 版本中,您可以执行以下操作以延长 toastr 的显示时间:

        toastr.success('Hello World', 'New Message', { timeOut: 9500 });
        

        【讨论】:

        • 正是我想要的。我需要更长的超时时间以便我有机会看到通知,因为 Microsoft Edge 已将下载弹出框放在右上角,覆盖了我的通知!
        猜你喜欢
        • 1970-01-01
        • 2023-03-17
        • 2013-05-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多