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
相关文章
|
Android开发
Android实现语音播报的两种方式
Android实现语音播报的两种方式
1170 0
|
小程序 Windows
uniapp运行微信小程序routeDone的错误问题
uniapp运行微信小程序routeDone的错误问题
3475 0
|
机器学习/深度学习 人工智能 达摩院
ModelScope 社区介绍和操作入门| 学习笔记
快速学习 ModelScope 社区介绍和操作入门
ModelScope 社区介绍和操作入门| 学习笔记
|
3月前
|
JSON 人工智能 API
Cursor 接入第三方 API 配置指南:Override Base URL 的正确用法与四个机制限制(2026年9月)
想在 Cursor 里接第三方渠道跑 Claude,唯一走得通的路径是 OpenAI 兼容协议 `/v1/chat/completions`,不能在 Anthropic 栏直接填第三方 Key。本文给出完整配置流程、端点验证方法,以及四个官方论坛可查证的机制限制。
2831 0
|
缓存 安全 API
android studio Gradle 打包任务配置
本文详解Android Studio中AGP自动生成的Gradle打包任务机制,涵盖`build.gradle`核心配置:签名管理、多渠道构建、APK/AAB输出命名,以及CI/CD集成技巧。系统梳理打包流程,提供安全、高效、可追溯的发布实践方案。(238字)
1317 0
|
7月前
|
Rust JavaScript Java
PHP已死?谎言与真相:2025年PHP生态现状、薪资趋势与未来前景
每隔几年,技术圈就会响起“PHP已死”的论调。然而现实是,直至2025年,PHP仍然驱动着超过77%的网站,WordPress市场占有率持续攀升,Laravel和Symfony社区依然活跃。
1025 0
|
Linux 应用服务中间件 数据安全/隐私保护
如何重置阿里云服务器密码?
本文介绍了如何重置阿里云服务器密码,包括设置新密码的流程及注意事项。内容涵盖登录控制台、选择服务器、重置密码参数配置等步骤,并详细说明了在线和离线修改密码的不同场景及操作方式,适用于Windows和Linux实例,默认用户名分别为Administrator和root。
|
Web App开发 编解码 vr&ar
Deepseek解读 | UE像素流送与实时云渲染技术的差别
为了实现UE引擎开发的3D/XR程序推流,开发者通常使用像素流送(Pixel Streaming)技术。它通过WebRTC协议将服务器端渲染的画面传输到客户端,适用于短时、少并发场景。然而,在项目落地阶段,其局限性显现,实时云渲染方案成为更好的选择。Deepseek分析表明,实时云渲染具备高性能分布式渲染、低延迟传输、多平台支持等优势,特别适合高复杂度场景和大规模应用。Paraverse平行云的LarkXR产品,作为领先的实时云渲染解决方案,提供高质量、低延迟的渲染体验,支持多种3D引擎和XR内容格式,具备弹性扩展和成本优化等特点,广泛应用于元宇宙、虚拟仿真等领域。
|
人工智能 自然语言处理 算法
接入DeepSeek需要做算法备案吗?一文读懂算法备案的那些事儿
在AI快速发展的今天,算法备案成为企业合规运营的关键。本文通过五个案例解析接入DeepSeek是否需备案:1) 微调模型需备案,流程4-6个月;2) 面向公众服务需备案;3) 内部使用通常无需备案;4) 个人自用无需备案;5) 面向特定专业人士通常无需备案。了解这些要求,确保企业在享受AI红利的同时合规运营,规避风险。
|
计算机视觉
【YOLOv8改进】Inner-IoU: 基于辅助边框的IoU损失(论文笔记+引入代码)
YOLO目标检测专栏探讨了IoU损失的局限性,并提出创新改进。分析发现,不同尺度的辅助边框对高IoU和低IoU样本的回归有不同影响。因此,提出了Inner-IoU Loss,利用尺度因子ratio控制辅助边框大小以优化损失计算。实验验证了该方法能提升检测效果,增强泛化能力。创新点包括根据样本特性选择辅助边框尺度和Inner-IoU Loss的设计。更多详情见YOLO目标检测创新改进与实战案例专栏。