将 didOpen sweetalert2 参数的值传递给 .then
passing a value from didOpen sweetalert2 parameter to the .then
我已经构建了 didOpen 参数并实现了一个 JSON 对象,其中包含值。
问题是...如何将 JSON 对象传递给 Swal.fire({ }) 的 then 部分。then 箭头函数
Swal.fire({
html: ` HERE IS ALL THE ID's STUFF `,
didOpen() {
let itemPOST = {
/* the json i trying to catch */ }
// do bunch of stuff and save it into itemPOST
} //==>end of didOpen
}).then(() => {
//console log here for itemPOST
})
解决方案是在 swal 之后包含一些变量,将值传递给该变量并在 .then() 箭头函数中调用它
let giveMeTheValue; //<== variable to receive the value
Swal.fire({
html: ` HERE IS ALL THE ID's STUFF `,
didOpen() {
let itemPOST = { /* the json with data */ }
// do bunch of stuff and save it into itemPOST
giveMeTheValue = itemPOST //<== giving the data to pass to then()
}
}).then(() => {
console.log(giveMeTheValue)
})
我已经构建了 didOpen 参数并实现了一个 JSON 对象,其中包含值。
问题是...如何将 JSON 对象传递给 Swal.fire({ }) 的 then 部分。then 箭头函数
Swal.fire({
html: ` HERE IS ALL THE ID's STUFF `,
didOpen() {
let itemPOST = {
/* the json i trying to catch */ }
// do bunch of stuff and save it into itemPOST
} //==>end of didOpen
}).then(() => {
//console log here for itemPOST
})
解决方案是在 swal 之后包含一些变量,将值传递给该变量并在 .then() 箭头函数中调用它
let giveMeTheValue; //<== variable to receive the value
Swal.fire({
html: ` HERE IS ALL THE ID's STUFF `,
didOpen() {
let itemPOST = { /* the json with data */ }
// do bunch of stuff and save it into itemPOST
giveMeTheValue = itemPOST //<== giving the data to pass to then()
}
}).then(() => {
console.log(giveMeTheValue)
})