百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

sweetalert2-react-content

> 前端框架
开源

官方的 SweetAlert2 增强程序,增加了对 React 元素作为内容的支持

730 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

官方的 SweetAlert2 增强程序,增加了对 React 元素作为内容的支持

sweetalert2-React-content

官方 SweetAlert2 增强器,增加了对 React 元素作为内容的支持。

  • 简单示例: https://sweetalert2.github.io/recipe-gallery/sweetalert2-react.html
  • 使用 React 路由器: https://sweetalert2.github.io/recipe-gallery/sweetalert2-react-router.html
  • 使用 React-day-picker: https://sweetalert2.github.io/recipe-gallery/input-datepicker.html

以下选项可以作为 React 元素:

  • title
  • html
  • confirmButtonText
  • denyButtonText
  • cancelButtonText
  • footer
  • closeButtonHtml
  • iconHtml
  • loaderHtml

安装

bash
npm install sweetalert2 sweetalert2-react-content

使用示例

javascript
import Swal from 'sweetalert2'
import withReactContent from 'sweetalert2-react-content'

const MySwal = withReactContent(Swal)

MySwal.fire({
  title: 
Hello World
,
  didOpen: () => {
    // `MySwal` is a subclass of `Swal` with all the same instance & static methods
    MySwal.showLoading()
  },
}).then(() => {
  return MySwal.fire(
Shorthand works too
)
})

dist/sweetalert2-React-content.umd.js 文件在非 CJS/AMD 环境中定义了 window.sweetalert2ReactContent。

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScriptreactsweetalertsweetalert2

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架