我不知道如何在 sweet
alert 中添加 textarea
类型。
类似于 type: "input"
。
$('#saveBtn).click(function(){
swal({
title: "Enter your Name!",
text: "your name:",
type: "input",
showCancelButton: true,
closeOnConfirm: false,
showLoaderOnConfirm: true,
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");
});
});
这个可以正常工作。但是如果我使用type: "textarea"
而不是type: "input"
,就会出现以下错误:
sweetalert.min.js:1 Uncaught ReferenceError: logStr is not defined
感谢您的帮助。
title: "请输入您的姓名!",
text: "您的姓名:",
type: "input",
showCancelButton: true,
closeOnConfirm: false, showLoaderOnConfirm: true, animation: "slide-from-top",
inputPlaceholder: "写点什么" }, function(inputValue){
if (inputValue === false) return false;
if (inputValue === "") { swal.showInputError("您需要写点东西!");
return false } swal("好极了!", "您输入的是:" + inputValue, "success"); }); }); - Prafull Pol