1

我正在使用最新版本的 Bootstrap Notify (v3.1.5) 在 AJAX 调用后显示状态消息。它在第一次通话中按预期工作。第一次执行后,每次调用 notify 时,都会显示之前的通知消息。

例子:

第一次通话 = 1 条通知消息;第 2 次通话 = 2 条通知消息;第 3 次通话 = 3 条通知消息;...

引导通知初始化:

$.notify({
    icon: icon,
    title: title,
    message: message
}, {
    type: type,
    allow_dismiss: true,
    newest_on_top: false,
    placement: {
        from: "top",
        align: "right"
    },
    offset: 20,
    spacing: 10,
    z_index: 100000,
    delay: delay,
    timer: 1000,
    mouse_over: true,
    animate: {
        enter: 'animated fadeInDown',
        exit: 'animated fadeOutUp'
    }
});

我该如何解决这个问题?

4

2 回答 2

1

您可以通过使用获取所有通知长度来阻止并阻止它。如果 notify 大于 0 返回 false;

let notifylength = document.querySelectorAll('.bootstrap-notify-container');
if(notifylength.length !== 0){
    return false;
}
于 2020-08-28T13:27:47.420 回答
1

解决了我的问题。经过一些调试后,我意识到该事件被多次触发,导致通知反复弹出。真是菜鸟大错……

于 2017-02-21T12:47:03.400 回答