0

在简单的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);
4

0 回答 0