javascript - 一个接一个地运行多个sweetalerts
问题描述
我试图在彼此之后运行多个sweetalerts,但我现在拥有的代码只是执行最后一个。有谁知道为什么以及如何解决这个问题?
const { value: inhalt } = Swal.fire({
title: 'Neue Ladegüter',
text: 'Geben Sie einen Inhalt an:',
input: 'text',
showCancelButton: true,
inputValidator: (value) => {
if (!value) {
return 'Field cannot be empty'
}
}
});
const { value: beschreibung } = Swal.fire({
title: 'Neue Ladegüter',
text: 'Geben Sie eine Beschreibung an:',
input: 'text',
showCancelButton: true,
inputValidator: (value) => {
if (!value) {
return 'Field cannot be empty'
}
}
});
解决方案
当您调用警报时,它将关闭最后一个,然后打开新的。它使用一个容器来显示警报。你应该在最后一个警报的响应上调用其他警报。
编辑:添加示例
Swal.fire({
title: 'Neue Ladegüter',
text: 'Geben Sie einen Inhalt an:',
input: 'text',
showCancelButton: true,
inputValidator: (value) => {
if (!value) {
return 'Field cannot be empty'
}
}
}).then((res)=>{
Swal.fire({
title: 'Neue Ladegüter',
text: 'Geben Sie eine Beschreibung an:',
input: 'text',
showCancelButton: true,
inputValidator: (value) => {
if (!value) {
return 'Field cannot be empty'
}
}
});
});
推荐阅读
- python - 删除文件中的每个空行 - Python/JSONl
- python - 直接在 Kubernetes pod 中访问我的 Flask 应用程序日志
- c# - 如何使用 C# 将 SharePoint 站点文件夹映射为网络驱动器?
- json - Golang json 解组
- abap - 如何在消息文本中转义与号?
- go - 如何获取 Gorm 查询计数结果
- sas - 按变量 X 中字符串的长度对所有行进行排序(首先是较长的字符串)
- mysql - 来自 GET 的 MySQL 循环更新数据
- java - 片段未显示在家庭活动中
- c# - 错误:合并两个分支后在运行时出现“无法加载文件或程序集 Newtonsoft.Json”。两个分支都运行良好