我使用sweetalert2验证电子邮件地址,但我希望它显示输入名称的文本输入。我理解它是连锁模态,但我不能为我的生活弄清楚如何从页面上给出的例子?
var cloud_email = $('.cloud_email').text();
var user_name = $('.user_name').text();;
swal.setDefaults({
confirmButtonText: 'Next →',
showCancelButton: true,
animation: false
});
var steps = [
{
//ask for and validate email here
type: 'question',
title: 'Please enter email address',
input: 'email',
inputValue: cloud_email
},
{
//ask for and validate text input here
type: 'question',
title: 'Please enter user name',
input: 'text',
inputValue: user_name
}
];
swal.queue(steps).then(function(email, name) {
swal({
type: 'success',
html: 'Email successfully sent to: ' + name + ': '+ email
});
}).finally(function() {
swal.resetDefaults();
//ajax to process values passed
})
我的尝试返回此错误:
swal.queue(...).then(...).finally is not a function
答案 0 :(得分:2)
要使用finally()
方法,您应在网页中加入polyfill for Promise.prototype.finally,例如:
<script src="https://cdn.jsdelivr.net/promise.prototype.finally/1.0.1/finally.js"></script>
PS。我刚刚将Promise.prototype.finally
polyfill的链接添加到示例页面:https://sweetalert2.github.io/#chaining-modals