gpt4 book ai didi

javascript - 重复的 toastr 错误消息

转载 作者:数据小太阳 更新时间:2023-10-29 05:02:25 26 4
gpt4 key购买 nike

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

这是我的 toastr 默认值:

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

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

最佳答案

这可能有帮助

toastr.options = {
"preventDuplicates": true,
"preventOpenDuplicates": true
};

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

关于javascript - 重复的 toastr 错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27365538/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com