Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery PNotify=左下角配置不';我不能正常工作_Jquery_Pnotify - Fatal编程技术网

Jquery PNotify=左下角配置不';我不能正常工作

Jquery PNotify=左下角配置不';我不能正常工作,jquery,pnotify,Jquery,Pnotify,使用Pnotify插件 我试图将它重新定位到屏幕的左下角,并让它向上推连续的菜单 定位不是问题,但通知的方向都是相互叠加的(我只看到最新的通知,其余的都在后面) 代码应该是直截了当的 var stack_bottomleft = {"dir1": "up", "dir2": "up", "push": "top"}; new PNotify({ title: "Title", type: "Succes

使用Pnotify插件

我试图将它重新定位到屏幕的左下角,并让它向上推连续的菜单

定位不是问题,但通知的方向都是相互叠加的(我只看到最新的通知,其余的都在后面)

代码应该是直截了当的

 var stack_bottomleft = {"dir1": "up", "dir2": "up", "push": "top"};

            new PNotify({
                title: "Title",
                type: "Success",
                text: "My Message 1",
                animation: "fade",
                animate_speed: 'fast',

                addclass: "stack-bottomleft",
                stack:    stack_bottomleft

            });

            new PNotify({
                title: "Title",
                type: "Success",
                text: "My Message 2",
                animation: "fade",
                animate_speed: 'fast',

                addclass: "stack-bottomleft",
                stack:    stack_bottomleft

            });


            new PNotify({
                title: "Title",
                type: "Success",
                text: "My Message 3",
                animation: "fade",
                animate_speed: 'fast',

                addclass: "stack-bottomleft",
                stack:    stack_bottomleft

            });

可能是一个bug?

您必须注意在哪里创建堆栈。例如,不要在if语句中创建它,因为它将为每个通知创建一个新堆栈,并且堆栈将重叠。我在pnotify主页的index.html评论中发现了这一点:

我也有同样的问题:

            $rootScope.$watch('feedback',function(){
                if($rootScope.feedback){
                 var stack_bottomleft = {"dir1": "up", "dir2": "right", "firstpos1": 25, "firstpos2": 25};
                    new PNotify({
                        title: $rootScope.feedback.title,
                        text: $rootScope.feedback.text,
                        type: $rootScope.feedback.type,
                        addclass: 'stack-bottomleft',
                        stack: stack_bottomleft
                    });
                    $rootScope.feedback=null;
                }
            });
并通过以下方式对其进行了修复:

var stack_bottomleft = {"dir1": "up", "dir2": "right", "firstpos1": 25, "firstpos2": 25};
            $rootScope.$watch('feedback',function(){
                if($rootScope.feedback){
                    new PNotify({
                        title: $rootScope.feedback.title,
                        text: $rootScope.feedback.text,
                        type: $rootScope.feedback.type,
                        addclass: 'stack-bottomleft',
                        stack: stack_bottomleft
                    });
                    $rootScope.feedback=null;
                }
            });
我希望这对你有帮助

就像以前一样,在通知init内设置堆栈对象和将堆栈对象传输到通知init参数之间有一个关键的区别

因此,即使是下一个代码也无法工作:

var showNotice = function () {
    var stack = {dir1: "up", dir2: "left", firstpos1: 25, firstpos2: 25},

    return new PNotify({
        title: 'Some title', text: 'Some text',
        addclass: "stack-bottomright",
        stack: stack
    });
}
这里的要点是,相同的堆栈通知应该接收为其配置的同一个堆栈对象。在上面所示的情况下,新对象将在每次函数调用时初始化,并且每个通知将接收不同的对象

为了避免这种情况,所有通知都应该指向同一个对象。例如:

    var stack = {dir1: "up", dir2: "left", firstpos1: 25, firstpos2: 25},
        showNotice = function () {     
            return new PNotify({
                title: 'Some title', text: 'Some text',
                addclass: "stack-bottomright",
                stack: stack
            });
        }
这样做,以后每次调用
showNotice()
都会处理上一个通知之前处理的堆栈对象

    var stack = {dir1: "up", dir2: "left", firstpos1: 25, firstpos2: 25},
        showNotice = function () {     
            return new PNotify({
                title: 'Some title', text: 'Some text',
                addclass: "stack-bottomright",
                stack: stack
            });
        }