官方的 SweetAlert2 增强程序,增加了对 React 元素作为内容的支持
官方 SweetAlert2 增强器,增加了对 React 元素作为内容的支持。
以下选项可以作为 React 元素:
titlehtmlconfirmButtonTextdenyButtonTextcancelButtonTextfootercloseButtonHtmliconHtmlloaderHtmlnpm install sweetalert2 sweetalert2-react-contentimport 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,或尚未同步最近议题。