gpt4 book ai didi

sweetalert - 是否可以在 sweetAlert 框中添加复选框?

转载 作者:行者123 更新时间:2023-12-02 17:27:52 30 4
gpt4 key购买 nike

我可以将 inputType 设置为密码。支持哪些其他输入类型?

       swal({
title: "Are you sure?",
type: "input",
inputType: "checkbox",
showCancelButton: true,
closeOnConfirm: true,
}, function () {
swal("", "You did it", "success");
});

swal 不支持复选框 inputType..

最佳答案

SweetAlert2 中有一个使用 checkbox 模态类型的好方法。 :

Swal.fire({
title: 'Do you have a bike?',
input: 'checkbox',
inputPlaceholder: 'I have a bike'
}).then((result) => {
if (result.isConfirmed) {
if (result.value) {
Swal.fire({icon: 'success', text: 'You have a bike!'});
} else {
Swal.fire({icon: 'error', text: "You don't have a bike :("});
}
} else {
console.log(`modal was dismissed by ${result.dismiss}`)
}
})
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

PS。请注意,SweetAlert2 与 SweetAlert 略有不同,请查看简单的迁移指南: https://github.com/sweetalert2/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2

关于sweetalert - 是否可以在 sweetAlert 框中添加复选框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48781890/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com