JavaScript练习 - promise转async/awa

2021-07-08  本文已影响0人  张中华
function generatePromise() {
    return new Promise(function(resolve,reject){
        resolve('Hello World');
    });
}


async function execute() {
    let promise = generatePromise();
    console.log('1');
    const a = async() => promise.then(x => console.log(x));
    await a();
    console.log('3');
}

execute();
上一篇下一篇

猜你喜欢

热点阅读