我可以将inputType设置为密码。支持的其他输入类型是什么?
swal({
title: "Are you sure?",
type: "input",
inputType: "checkbox",
showCancelButton: true,
closeOnConfirm: true,
}, function () {
swal("", "You did it", "success");
});
swal支持复选框inputType。
答案 0 :(得分:2)
在SweetAlert2中使用checkbox
模态类型的方法很简单:
Swal.fire({
title: 'Do you have a bike?',
input: 'checkbox',
inputPlaceholder: 'I have a bike'
}).then(function(result) {
if (result.value) {
Swal.fire({type: 'success', text: 'You have a bike!'});
} else if (result.value === 0) {
Swal.fire({type: '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@8"></script>
PS。请注意,SweetAlert2与SweetAlert略有不同,请查看简单的迁移指南:https://github.com/sweetalert2/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2