SweetAlert和JS提示框之间有什么区别

时间:2017-05-03 19:06:30

标签: javascript sweetalert sweetalert2

在简单的javascript代码中,提示框的输入正常工作

f = prompt ("write a number here") 
   r = 1;
   x = f-r;
   alert(x);

在设置带有sweetalert的提示框样式时,在写入输入值之前结果将为NaN

  f = swal({
  title: "An input!",
  text: "Write something interesting:",
  type: "input",
  showCancelButton: true,
  closeOnConfirm: false,
  animation: "slide-from-top",
  inputPlaceholder: "Write something"
},
function(inputValue){
  if (inputValue === false) return false;

  if (inputValue === "") {
    swal.showInputError("You need to write something!");
    return false
  }

  swal("Nice!", "You wrote: " + inputValue, "success");
});

   r = 1;
   x = f-r;
   alert(x);

0 个答案:

没有答案