屏幕上有多个通知,关闭通知会关闭最后一个通知
With multiple notifications on screen, closing a notification closes the last notification
我正在使用 NOTY (notification library) version 3.0.0 显示来自 JavaScript 的通知弹出窗口。
当屏幕上有多个通知时,当我点击关闭按钮时,它总是关闭屏幕上的最后一个通知。我知道这是因为变量 n 总是被示例代码中的最后一个通知对象覆盖。但是,我没有在文档中找到任何关于如何在多个通知的情况下处理通知关闭的线索。
我应该创建一个通知对象数组,然后像这样 n[i].close() 调用 .close() 函数,还是我们有更好的方法来实现这一点?
请帮忙
示例代码:
var n = new Noty({
type: 'success',
layout: 'bottomRight',
theme: 'relax',
text: "<b>Testing 2<br/><br/> ",
timeout: false,
closeWith: ['button'],
animation: {
open: 'noty_effects_open',
close: 'noty_effects_close'
},
buttons: [
Noty.button('CLOSE', 'btn btn-error', function () {
console.log('button 2 clicked');
n.close();
})
],
}).show();
我认为您可以使用 queue
功能,您可以在其中将多个对象推送到队列变量,并可以使用以下示例操作这些对象
Noty.closeAll(); // Closes all notifications
Noty.closeAll('myCustomQueueName'); // Closes all notifications with queue named 'myCustomQueueName'
Noty.setMaxVisible(10); // Sets the maxVisible notification count for global queue;
Noty.setMaxVisible(10, 'myCustomQueueName'); // Sets the maxVisible notification count for 'myCustomQueueName' queue;
我正在使用 NOTY (notification library) version 3.0.0 显示来自 JavaScript 的通知弹出窗口。
当屏幕上有多个通知时,当我点击关闭按钮时,它总是关闭屏幕上的最后一个通知。我知道这是因为变量 n 总是被示例代码中的最后一个通知对象覆盖。但是,我没有在文档中找到任何关于如何在多个通知的情况下处理通知关闭的线索。
我应该创建一个通知对象数组,然后像这样 n[i].close() 调用 .close() 函数,还是我们有更好的方法来实现这一点? 请帮忙
示例代码:
var n = new Noty({
type: 'success',
layout: 'bottomRight',
theme: 'relax',
text: "<b>Testing 2<br/><br/> ",
timeout: false,
closeWith: ['button'],
animation: {
open: 'noty_effects_open',
close: 'noty_effects_close'
},
buttons: [
Noty.button('CLOSE', 'btn btn-error', function () {
console.log('button 2 clicked');
n.close();
})
],
}).show();
我认为您可以使用 queue
功能,您可以在其中将多个对象推送到队列变量,并可以使用以下示例操作这些对象
Noty.closeAll(); // Closes all notifications
Noty.closeAll('myCustomQueueName'); // Closes all notifications with queue named 'myCustomQueueName'
Noty.setMaxVisible(10); // Sets the maxVisible notification count for global queue;
Noty.setMaxVisible(10, 'myCustomQueueName'); // Sets the maxVisible notification count for 'myCustomQueueName' queue;