我正在尝试使用Noty插件在我的应用程序中创建通知。
不幸的是,这些文档更加复杂,我可以理解。因此,我无法生成一个简单的警报,出现在屏幕的右上方。
这就是我所做的。
首先,我包括了以下两个文件
noty/js/noty/jquery-noty.js
noty/js/noty/layouts/topRight.js我添加了这样的默认配置
$(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
};
});然后,我添加了一个单击事件来触发这样的通知
$(function(){
$('#test').click(function(){
noty({
text: 'Simple Test!'
});
});
});当我单击“测试”按钮时,屏幕上没有任何内容,控制台中也没有任何错误。
我在这里做错什么了?如何创建一个出现在右上角的简单通知?
发布于 2016-09-11 01:08:02
template设置在$.noty.defaults中为空。试着提供一个:
template: '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',https://stackoverflow.com/questions/39431365
复制相似问题