概述

  • 创建可以被拨动显示的通知,并且能自动淡出。当你将鼠标悬停在通知上面时,它不会自动消失,直到你移开鼠标。还可以通过点击关闭通知。
实例
            
$('#j-btn').on('click', function() {
    $.notify('<h3>提示</h3><p>您有新的消息</p>')
  })
            
          

内容图标

  • 可以在通知信息内嵌HTML,比如 图标
实例






            
$('#j-btn-2').on('click', function() {
  $.notify({ icon: 'info', message: '<p>我是有info图标的!<p/p><p>朕知道了<p/p>'});
})
$('#j-btn-5').on('click', function() {
  $.notify({ icon: 'success', message: '<pp>我是有success图标的!<p/p><p>朕知道了</p>'});
})
$('#j-btn-6').on('click', function() {
  $.notify({ icon: 'warning', message: '<p>我是有warning图标的!<p/p><p>朕知道了</p>'});
})
$('#j-btn-7').on('click', function() {
  $.notify({ icon: 'error', message: '<pp>我是有error图标的!<p/p><p>朕知道了<p/p>'});
})
            
          

定时/延迟

  • 我们可以设置timeout通知信息隐藏的时间。若设置为0,则不隐藏!
实例
            
$('#j-btn-3').on('click', function() {
  $.notify({ message: '<div class="notify-bfc"><i class="icon-done"></i> <div><p>我是有图标的!</p><p>朕知道了</p></div></div>', timeout: 1000});
})
            
          

定位

  • 添加以下参数中的一个来调整通知出现的位置。
实例
属性 描述 示例
'top-center' $.notify({message:'顶部居中', pos: 'top-center'})
'top-left' $.notify({message: '左上角', pos: 'top-left'})
'top-right' $.notify({message: '右上角', pos: 'top-right'})
'bottom-center' $.notify({message: '底部居中', pos: 'bottom-center'})
'bottom-left' $.notify({message: '左下角', pos: 'bottom-left'})
'bottom-right' $.notify({message: '右下角', pos: 'bottom-left'})
'vcenter' $.notify({message: '居中', pos: 'vcenter'})
'icon' $.notify({message: '居中', icon: 'info'}) 显示图标icon
            
$('#j-btn-3').notify({ message: ' 我是有图标的!', pos: 'bottom-center'});
            
          

配置

实例
选项 类型 默认值 描述
message String '' 提示内容
status String '' 状态颜色类名
opacity Float 0.85 透明度
timeout Int 5000 定时延迟消失
group String null 是否分组
pos String top-center 位置
onClose Function noop 关闭触发事件