The mes
argument in your 2nd .then()
comes from the return value of the first .then()
handler. If you don't return anything from that first .then()
handler, then you don't get any resolved value in the 2nd .then()
handler and mes
will be undefined
.
Plus, the 2nd .then()
handler will only "wait" for the load_img(url2)
to resolve if you return its promise from within the first .then()
handler. This is how you properly chain promises.
Perhaps you're just using this code for testing, but you do not have to load your two images in sequence since the 2nd one does not depend upon the first one. You could load them in parallel and use Promise.all()
to know when they are both done.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…