Toastr JS无限期地保持Toast可见

Toastr JS keep toasts visible indefinitely

本文关键字:Toast 可见 JS 无限期 Toastr      更新时间:2023-09-26

我正在尝试使用John Papa的Toastr插件显示Toast消息。(http://codeseven.github.io/toastr/demo.html)我无法找到一个选项,让吐司无限期地保留在屏幕上,而无需手动将"超时"和"扩展超时"值设置为荒谬的高值。有谁知道一种方法可以做到这一点?

toastr.options = {
    "closeButton": true,
    "timeOut": "500000",
    "extendedTimeOut": "100000"
}
toastr.error('Error!');

根据代码,将它们设置为 0

timeOut: 5000, // Set timeOut and extendedTimeout to 0 to make it sticky

若要在用户关闭之前显示 toast,请设置禁用超时并关闭按钮

        toastr.error("Message", "Title", { disableTimeOut: true, closeButton:true });