代码之家  ›  专栏  ›  技术社区  ›  Kavvson Empcraft

提示-队列窗体

  •  1
  • Kavvson Empcraft  · 技术社区  · 8 年前

    您好,我想知道是否可以从-Chaining modals(queue)示例中获取输入数据。它只返回一个通用的值数组,是否可能从中获取类似字段名和值的内容?据我所知,没有解决办法。

    swal.mixin({
      input: 'text',
      confirmButtonText: 'Next →',
      showCancelButton: true,
      progressSteps: ['1', '2', '3']
    }).queue([
      {
        title: 'Question 1',
        text: 'Chaining swal2 modals is easy'
      },
      'Question 2',
      'Question 3'
    ]).then((result) => {
      if (result.value) {
        swal({
          title: 'All done!',
          html:
            'Your answers: <pre>' +
              JSON.stringify(result) +
            '</pre>',
          confirmButtonText: 'Lovely!'
        })
      }
    })
    

    Your answers:
    {"value":["question 1","question 2","question 3"]}
    

    谢谢你的帮助。

    Sweet Alerts 2

    1 回复  |  直到 8 年前
        1
  •  1
  •   user10757375 user10757375    7 年前

    你可以用 preConfirm

    var strAns1;
    var strAns2;
    
    swal.mixin({
      input: 'text',
      confirmButtonText: 'Next &rarr;',
      showCancelButton: true,
      progressSteps: ['1', '2', '3']
    }).queue([
      {
        title: 'Question 1',
        text: 'Chaining swal2 modals is easy',
        preConfirm: function(value)
                {
                    strAns1= value;
                }
      },
    
      {
        title: 'Question 2',
        text: 'Chaining swal2 modals is easy',
        preConfirm: function(value)
                {
                    strAns2= value;
                }
      }
    ]).then((result) => {
      if (result.value) {
        swal({
          title: 'All done!',
          html:
            'Your answers: <pre>' +
              JSON.stringify(result) +
            '<pre>Answer1- ' + strAns1+
            '<pre>Answer2- ' + strAns2+
            '</pre>',
          confirmButtonText: 'Lovely!'
        })
      }
    })
    
    推荐文章