首页 > 解决方案 > 在 Javascript 中几秒钟后关闭 toastr.error

问题描述

toastr.error('Testing pop-up')当应用程序出现错误时,我使用Javascript向我显示一个弹出窗口,但我在官方文档中看不到如何在 X 秒后自动关闭此弹出窗口而不按任何按钮。有谁知道怎么做?

标签: javascript

解决方案


您可以设置超时,如:

超时
通过适当设置超时来控制 toastr 如何与用户交互。

toastr.options.timeOut = 30; // How long the toast will display without user interaction
toastr.options.extendedTimeOut = 60; // How long the toast will display after a user hovers over it

参考:


推荐阅读