toastify-js

简介: toastify-js

分享一个前端消息提示组件库ToastifyJs

https://github.com/apvarun/toastify-js

引入:

npm install --save toastify-js

或者

<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">

<script src="https://cdn.jsdelivr.net/npm/toastify-js"></script>

使用:

Toastify({ text: "This is a toast", duration: 3000 }).showToast();

复杂例子:

Toastify({
  text: "This is a toast",
  duration: 3000,
  destination: "https://github.com/apvarun/toastify-js",
  newWindow: true,
  close: true,
  gravity: "top", // `top` or `bottom`
  position: "left", // `left`, `center` or `right`
  stopOnFocus: true, // Prevents dismissing of toast on hover
  style: {
    background: "linear-gradient(to right, #00b09b, #96c93d)",
  },
  onClick: function(){} // Callback after click
}).showToast();

完整api:

Option Key type Usage Defaults
text string Message to be displayed in the toast “Hi there!”
node ELEMENT_NODE Provide a node to be mounted inside the toast. node takes higher precedence over text
duration number Duration for which the toast should be displayed.
-1 for permanent toast
3000
selector string | ELEMENT_NODE ShadowRoot CSS Selector or Element Node on which the toast should be added
destination URL string URL to which the browser should be navigated on click of the toast
newWindow boolean Decides whether the destination should be opened in a new window or not false
close boolean To show the close icon or not false
gravity “top” or “bottom” To show the toast from top or bottom “top”
position “left” or “right” To show the toast on left or right “right”
backgroundColor CSS background value To be deprecated, use style.background option instead. Sets the background color of the toast
avatar URL string Image/icon to be shown before text
className string Ability to provide custom class name for further customization
stopOnFocus boolean To stop timer when hovered over the toast (Only if duration is set) true
callback Function Invoked when the toast is dismissed
onClick Function Invoked when the toast is clicked
offset Object Ability to add some offset to axis
escapeMarkup boolean Toggle the default behavior of escaping HTML markup true
style object Use the HTML DOM Style properties to add any style directly to toast
ariaLive string Announce the toast to screen readers, see ARIA live regions - Accessibility | MDN for options “polite”
oldestFirst boolean Set the order in which toasts are stacked in page true
相关文章
|
JSON 关系型数据库 MySQL
Windows本地安装dataX教程及读写demo
DataX本身作为数据同步框架,将不同数据源的同步抽象为从源头数据源读取数据的Reader插件,以及向目标端写入数据的Writer插件,理论上DataX框架可以支持任意数据源类型的数据同步工作。同时DataX插件体系作为一套生态系统, 每接入一套新数据源该新加入的数据源即可实现和现有的数据源互通。
4719 0
Windows本地安装dataX教程及读写demo
|
关系型数据库 MySQL Java
Mysql开启ssl加密协议及Java客户端配置操作指南
本文主要讲述的是Mysql开启了ssl协议之后,Java客户端如何正确的链接Mysql访问数据
Mysql开启ssl加密协议及Java客户端配置操作指南
|
关系型数据库 MySQL Linux
Centos 7.2 系统安装mysql5.7.10指定版本
本文介绍在CentOS 7.2系统上安装MySQL 5.7.10的完整步骤,包括下载RPM包、解压、依赖处理、强制安装、服务启动与状态检查,并通过日志获取临时密码后修改为自定义密码,确保MySQL服务正常运行。
828 9
|
消息中间件 缓存 前端开发
WebSocket 与 MQTT 在即时通讯中的深度对比与架构选型指南
WebSocket 是双向通信通道,适合前端实时交互;MQTT 是轻量级消息协议,支持发布/订阅与可靠传输。二者互补,常结合使用:前端通过 WebSocket 接入,后端以 MQTT 实现高并发消息分发,构建可扩展的现代即时通讯系统。
2186 17
|
人工智能 JSON 测试技术
AI写代码的“上下文陷阱”:为什么AI总是写错?如何系统性解决?
本文探讨了如何充分利用AI模型能力进行编程协作
|
Ubuntu Linux 测试技术
Python 虚拟环境配置
本文总结了 Python 开发中的环境配置、常用操作和常见错误处理。重点介绍了如何使用 `virtualenv` 搭建虚拟环境,解决依赖冲突问题,并保持系统环境的干净。同时,详细说明了依赖库的安装与管理方法,包括使用 `pip install` 安装依赖、生成和使用 `requirements.txt` 文件,以及查看 Python 文档和修改环境变量等实用技巧。
1400 60
|
芯片
浮动CPU和定点CPU的主要区别是什么
浮动CPU和定点CPU的主要区别在于处理数据的方式不同。浮动CPU支持浮点运算,能高效处理小数和高精度计算;而定点CPU仅支持整数运算,适用于对精度要求不高的场景。
1247 3