天天看点

async await 基本使用方法

直接贴代码了,自己去打印看效果就会懂

async function async1() {
        console.log(1);
        const result = await async2();
        async3()
    }
    async function async2() {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve(2)
                console.log(2)
            }, 2000);
        })
    }
    function async3() {
       console.log(3)
    }
    async1();
           
async await 基本使用方法
async await 基本使用方法

喜欢上方小程序,需要源码的,私信小编留下邮箱。