
我真的不知道我在這里做錯了什么。SweetAlert 運行良好,但不顯示按鈕文本。
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover this imaginary file!",
icon: "warning",
buttons: true,
dangerMode: true,
});
uj5u.com熱心網友回復:
嘗試創建一個干凈的 html 頁面,如下所示:
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover this imaginary file!",
icon: "warning",
buttons: true,
dangerMode: true,
})
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
問題可能出在頁面中的其他腳本上,因為您的代碼應該可以正常作業,您可以嘗試像這樣使用 Sweetalert2:
Swal.fire({
title: 'Do you want to save the changes?',
showCancelButton: true,
confirmButtonText: 'CONFIRM',
denyButtonText: `CANCEL`,
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
// confirm button pressed
console.log("confirm")
} else if (result.isDismissed) {
// deny button pressed
console.log("deny")
}
})
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.all.min.js"></script>
編輯:
嘗試在其他腳本匯入之前在您的 HTML 頁面中添加 jquery,如下所示:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
uj5u.com熱心網友回復:
這是答案
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText: 'Yes',
cancelButtonText: "No",
closeOnConfirm: false,
closeOnCancel: false
},
或者
swal({
text: "Once deleted, you will not be able to recover this imaginary file!",
buttons: ["Yes", "No"],
});
或者
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
swal("Are you sure you want to do this?", {
buttons: ["Oh noez!", "Aww yiss!"],
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/346275.html
標籤:javascript 查询 甜甜的
