首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重复toastr错误消息

重复toastr错误消息
EN

Stack Overflow用户
提问于 2014-12-09 03:38:53
回答 9查看 18.9K关注 0票数 10

我正在使用Toastr 2.1 JavaScript库显示临时的用户输入验证错误消息。我将preventDuplicates选项设置为true。它不起作用--当用户连续快速单击验证按钮时,我仍然看到重复的消息(单击比“超时”更快)。

下面是我的toastr默认值:

代码语言:javascript
复制
function getDefaults() {
    return {
        tapToDismiss: true,
        toastClass: 'toast',
        containerId: 'toast-container',
        debug: false,

        showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
        showDuration: 300,
        showEasing: 'swing', //swing and linear are built into jQuery
        onShown: undefined,
        hideMethod: 'fadeOut',
        hideDuration: 1000,
        hideEasing: 'swing',
        onHidden: undefined,

        extendedTimeOut: 1000,
        iconClasses: {
            error: 'toast-error',
            info: 'toast-info',
            success: 'toast-success',
            warning: 'toast-warning'
        },
        iconClass: 'toast-info',
        positionClass: 'toast-top-right',
        timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
        titleClass: 'toast-title',
        messageClass: 'toast-message',
        target: 'body',
        closeHtml: '<button>&times;</button>',
        newestOnTop: true,
        preventDuplicates: true,
        progressBar: false
    };
}

是否需要进行任何其他更改以防止重复的错误消息?

EN

回答 9

Stack Overflow用户

发布于 2016-11-16 21:06:51

这可能会有所帮助

代码语言:javascript
复制
toastr.options = {
"preventDuplicates": true,
"preventOpenDuplicates": true
};

toastr.error("Your Message","Your Title",{timeOut: 5000});
票数 13
EN

Stack Overflow用户

发布于 2016-05-06 12:38:19

我相信它能像预期的那样工作

代码语言:javascript
复制
preventDuplicates: Prevent duplicates of the **last toast**.

也许这就是你要找的房子?

代码语言:javascript
复制
preventOpenDuplicates: Prevent duplicates of open toasts.
票数 4
EN

Stack Overflow用户

发布于 2016-01-06 05:07:12

我也遇到了同样的问题,结果证明toastr preventDuplicates选项不适用于数组消息(当前版本2.1.1)。您需要使用join将数组转换为字符串。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27365538

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档