The status of the promise can be passed on, but the value can only be received once, the effect is as follows
new Promise((resolve,reject)=>{
console.log("第一层")
resolve("数据a")
}).then(suc=>{ console.log(suc)}, //数据a
_=>{ console.log("then1")
}).then(suc=>{console.log(suc)},//并没有输出"数据a",而是输出undefined
_=>{console.log("then2Fail")
})
So how do you continue to pass the value? Use the change state learned in the previous article to pass the value, use the following
new Promise((resolve,reject)=>{
console.log("第一层")
resolve("数据a")
}).then(suc=>{ console.log(suc) //数据a
return Promise.resolve(suc)},
_=>{ console.log("then1")
}).then(suc=>{console.log(suc)},//数据a
_=>{console.log("then2Fail")
})