return不能中断promise的then的执行

在第一个then已经使用了return,但是第二个then还是执行了。

function hai() {
    return new Promise((reslove,reject)=>{
        setTimeout(()=>{
            reslove('hai')
        }
        , 1000)
    }
    ).then((x)=>{
        console.log(12345)
        return x + 12345
    }
    ).then((x)=>{
        console.log(54321)
        return x + 54321
    }
    );
}
async function waitMe() {
    let a = await hai()
    let b = await 1

    hai().then((x)=>{
        console.log(x, "xxx")
        return
    }
    )
    console.log(11, a)
    console.log(22, b)
}
waitMe()

原文地址:https://www.cnblogs.com/sunupo/p/15793177.html