美文网首页
JavaScript练习 - promise转async/awa

JavaScript练习 - promise转async/awa

作者: 张中华 | 来源:发表于2021-07-08 23:25 被阅读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();
    

    相关文章

      网友评论

          本文标题:JavaScript练习 - promise转async/awa

          本文链接:https://www.haomeiwen.com/subject/avmtpltx.html