在甜蜜警报2中,如何在加载时设置输入值 我的甜蜜警报代码
swal({
title: 'Are you sure?',
text: "You are going to send emails from the system. Please confirm",
showCancelButton: true,
input: 'email',
confirmButtonText: 'Submit',
confirmButtonColor: '#4aa0f1',
cancelButtonColor: '#898b8e',
confirmButtonText: 'Send'
}).then(function (email) {
send_email = email;
sentHtmtBody_send();
loadingIcon();
});
答案 0 :(得分:2)
我们可以添加另一个字段
inputValue : 'test value',
添加完整代码后,我们可以看到它像这样
swal({
title: 'Are you sure?',
text: "You are going to send emails from the system. Please confirm",
showCancelButton: true,
input: 'email',
inputValue: "E.g john",
confirmButtonText: 'Submit',
confirmButtonColor: '#4aa0f1',
cancelButtonColor: '#898b8e',
confirmButtonText: 'Send'
}).then(function (email) {
send_email = email;
sentHtmtBody_send();
loadingIcon();
});
答案 1 :(得分:1)
在sweetalert2上,我在此suggested way中实现了它:
let input = document.createElement("input");
input.value = 'test';
input.type = 'text';
input.className = 'swal-content__input';
swal('Please type:', {
content: input,
buttons: ['Cancel', 'Update']
})
.then(() => {
//
});