Toasts 插件

Toasts 插件提供简单的功能,可轻松创建 bootstrap Toast。

用法

此插件可以作为 jQuery 插件激活。

jQuery

jQuery API 提供了更可定制的选项,允许开发者处理 todo 列表复选框事件和取消选中事件。

$(document).Toasts('create', {
  title: 'Toast Title',
  body: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr.'
})
选项
名称 类型 默认 说明
position 字符串 Position.TOP_RIGHT Toast 的位置,可用选项:topRighttopLeftbottomRightbottomLeft
fixed 布尔值 true 是否将 Toast 容器设置为固定。
autohide 布尔值 false 是否自动隐藏 Toast
autoremove 布尔值 true 在关闭后是否自动移除 Toast
delay 整数 1000 自动隐藏延迟
fade 布尔值 true 是否淡化 Toast
icon 字符串 图标类(例如 fas fa-exclamation-triangle
image 字符串 图片 URL
imageAlt 字符串 图片备选文字
imageHeight 字符串 ‘25px’ Toast 的图片大小
title 字符串 Toast 标题
subtitle 字符串 Toast 副标题
close 布尔值 true 是否在 Toast 中添加关闭按钮
body 字符串 Toast 主体
class 字符串 Toast 的其他类
事件

所有事件都发送到 body

事件类型  说明
init.lte.toasts   在构造完成时触发
created.lte.toasts   在创建 Toast 时触发
removed.lte.toasts   在删除 Toast 时触发

示例:$('body').on('created.lte.toast', handleCreateEvent)

方法
方法 说明
create  创建 Toast

示例:$(document).Toasts('create', {title: 'Toast Title'})