longitutde
单击确认时,如何将内容:{element:“ input”}作为必填字段?
答案 0 :(得分:0)
您可以使用此功能:
swal({
title: 'Edit Variable',
input: 'text',
showCancelButton: true,
confirmButtonText: 'Update',
preConfirm: function (email) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
if (email === '') {
alert("err");
reject('err')
} else {
resolve()
}
}, 1000)
})
},
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.11.0/sweetalert2.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.11.0/sweetalert2.min.js"></script>
检查此示例