reactjs - SweetAlert : 需要增加文本区域的大小
问题描述
我无法增加text-area
甜蜜警报的pops-up
,我想根据我的规范重置它,我能够增加模态的高度和宽度,而不是text-area
. 需要输入
在 CSS 中尝试.swal-height
并给出了适当的. 但无法设置大小。.swal-width
classname
text-area
handleDelete() {
var delreq;
var response_data;
var response_jsonObj;
swal("Enter notes:", {
content: "input",
}).then((value) => {
isDeleted = "Yes";
delreq = {
"DeleteRequest":
[
{
"Param-1": val1,
"Param-2": val2,
"Param-3": "val3",
"Param-4": val4,
"Param-5": val5
}
]
};
console.log('delreq',delreq);
fetch('API_URL', {
headers: {
'Accept': 'application/json, text/plain, application/xml, */*',
'Content-Type': 'application/json',
'Access-Control-Allow-Headers': 'Content-Type',
},
method: 'POST',
body: JSON.stringify(delreq)
}
).then(response => {
if (response.status !== 200) {
return;
}
response.text().then(data => {
response_data = data;
response_jsonObj = JSON.parse(response_data);
this.setState({ delval: response_jsonObj });
});
}).catch(error => this.setState({ error }));
swal({
title: "Deleted Successfully!",
icon: "success",
confirmButtonText: 'OK'
}).then((okay) => {
if (okay) {
history.push('/page1');
history.push('/page2');
}
});
});
}
希望text-area
比现在出现的更大。
解决方案
这已经解决了。我使用了 SweetAlert 的最新版本,即 Sweetalert2,它让我的工作变得更轻松。我使用 SweetAlert2 官方网站 ( https://sweetalert2.github.io/ ) 的代码片段来完成任务。这里是 :
Swal.fire({
title: 'Submit your Github username',
input: 'text',
inputAttributes: {
autocapitalize: 'off'
},
showCancelButton: true,
confirmButtonText: 'Look up',
showLoaderOnConfirm: true,
preConfirm: (login) => {
return fetch(`//api.github.com/users/${login}`)
.then(response => {
if (!response.ok) {
throw new Error(response.statusText)
}
return response.json()
})
.catch(error => {
Swal.showValidationMessage(
`Request failed: ${error}`
)
})
},
allowOutsideClick: () => !Swal.isLoading()
}).then((result) => {
if (result.value) {
Swal.fire({
title: `${result.value.login}'s avatar`,
imageUrl: result.value.avatar_url
})
}
})
推荐阅读
- tensorflow - 当使用全部 4 个 GPU 时,Tensorflow 的 Multi_Gpu_Model 会导致 Ubuntu 18.04 操作系统崩溃
- node.js - 使用 Node 和 Express,如何从 server.get(..) 内部调用远程 API
- c# - 将 post 与 oData 一起使用
- python - 如何在 curl 中使用 bash 翻译此代码以在 python 中请求
- spring-data-jpa - 将 H2 sql 查询转换为 JPQL
- apache - Apache webgate 与 docker 应用程序的集成
- javascript - Ajax 没有得到成功响应
- java - 当观察者需要不同的参数来更新时,观察者设计模式中该怎么做
- amazon-web-services - 值为“bucket-owner-full-control”的 s3:x-amz-acl 是什么意思?
- c# - 窗体上的 WPF C# 运行时图形编辑器。最简单的解决方案