首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Noty插件获得基本通知?

如何使用Noty插件获得基本通知?
EN

Stack Overflow用户
提问于 2016-09-10 23:06:02
回答 1查看 1K关注 0票数 2

我正在尝试使用Noty插件在我的应用程序中创建通知。

不幸的是,这些文档更加复杂,我可以理解。因此,我无法生成一个简单的警报,出现在屏幕的右上方。

这就是我所做的。

首先,我包括了以下两个文件

代码语言:javascript
复制
noty/js/noty/jquery-noty.js
noty/js/noty/layouts/topRight.js

我添加了这样的默认配置

代码语言:javascript
复制
$(function(){

    $.noty.defaults = {
        layout: 'topRight',
        theme: 'defaultTheme',
        type: 'alert',
        text: '',
        dismissQueue: true, // If you want to use queue feature set this true
        template: '',
        animation: {
            open: { height: 'toggle' },
            close: { height: 'toggle' },
            easing: 'swing',
            speed: 500 // opening & closing animation speed
        },
        timeout: true, // delay for closing event. Set false for sticky notifications
        force: false, // adds notification to the beginning of queue when set to true
        modal: false,
        maxVisible: 5, // you can set max visible notification for dismissQueue true option
        closeWith: ['click'], // ['click', 'button', 'hover']
        callback: {
            onShow: function () { },
            afterShow: function () { },
            onClose: function () { },
            afterClose: function () { }
        },
        buttons: false // an array of buttons
    };

});

然后,我添加了一个单击事件来触发这样的通知

代码语言:javascript
复制
$(function(){

    $('#test').click(function(){
            noty({
                text: 'Simple Test!'
            });
    });
});

当我单击“测试”按钮时,屏幕上没有任何内容,控制台中也没有任何错误。

我在这里做错什么了?如何创建一个出现在右上角的简单通知?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-09-11 01:08:02

template设置在$.noty.defaults中为空。试着提供一个:

代码语言:javascript
复制
template: '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39431365

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档