我已经构建了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
})
发布于 2020-10-16 21:56:38
解决方案是在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)
})
https://stackoverflow.com/questions/64378624
复制相似问题