跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • sweetalert2 右上角关闭按钮如何修改?
未分類
22 5 月 2020

sweetalert2 右上角关闭按钮如何修改?

sweetalert2 右上角关闭按钮如何修改?

資深大佬 : wework 1

我第一次使用 https://github.com/sweetalert2/sweetalert2 做 modal 弹窗 ,引入了以下文件

<link rel=”stylesheet” href=”https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/8.11.8/sweetalert2.min.css” />

<script src=”https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/8.11.8/sweetalert2.all.min.js”></script>

然后 js 配置如下

Swal.fire({
title: data.title,
html: data.html,
type: “success”,
showCancelButton: false,
showConfirmButton: false,
showCloseButton: true
})

配置文件里面,我已经设置了显示关闭按钮,弹窗右上角确实有了那个按钮,但是默认按钮文本是 submit

<button type=”button” class=”swal2-close” aria-label=”Close this dialog” style=”display: flex;”>submit</button>

我在官方文档那里好像找不到修改 关闭按钮文字的方法,有哪位朋友知道怎么修改么?

大佬有話說 (6)

  • 主 資深大佬 : wework

    哎,自己强制用 jquery 给他改值了 $(“.swal2-close”).text(‘X’);

  • 資深大佬 : w292614191

    改源码
    或者
    buttonText 之类的。

  • 主 資深大佬 : wework

    @w292614191 没有 closeButtonText 的属性,超恶心的

  • 資深大佬 : w292614191

    这个看起来,挺好看的。17 年的时候用过一下下。

  • 資深大佬 : w292614191

    @wework

    closeButtonHtml
    这个属性,可以传入 html 。

  • 資深大佬 : w292614191

    @wework
    closeButtonHtml
    Use this to change the content of the close button.

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具