3

メールアドレスの検証に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
4

1 に答える 1

2

finally()メソッドを使用するには、 Promise.prototype.finally のポリフィルをページに含める必要があります。

<script src="https://cdn.jsdelivr.net/promise.prototype.finally/1.0.1/finally.js"></script>

PS。Promise.prototype.finallyサンプル ページにポリフィルへのリンクを追加しました: https://sweetalert2.github.io/#chaining-modals

于 2016-08-17T00:50:27.863 に答える