我正在使用Toastr 2.1 JavaScript库显示临时的用户输入验证错误消息。我将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>×</button>',
newestOnTop: true,
preventDuplicates: true,
progressBar: false
};
}是否需要进行任何其他更改以防止重复的错误消息?
发布于 2016-11-16 21:06:51
这可能会有所帮助
toastr.options = {
"preventDuplicates": true,
"preventOpenDuplicates": true
};
toastr.error("Your Message","Your Title",{timeOut: 5000});发布于 2016-05-06 12:38:19
我相信它能像预期的那样工作
preventDuplicates: Prevent duplicates of the **last toast**.也许这就是你要找的房子?
preventOpenDuplicates: Prevent duplicates of open toasts.发布于 2016-01-06 05:07:12
我也遇到了同样的问题,结果证明toastr preventDuplicates选项不适用于数组消息(当前版本2.1.1)。您需要使用join将数组转换为字符串。
https://stackoverflow.com/questions/27365538
复制相似问题