天天看點

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 基本使用方法

喜歡上方小程式,需要源碼的,私信小編留下郵箱。