异步变成asycn、

xiaoxiao2025-07-16  10

异步变成async、await

function funcTimer1(aaa) { return new Promise((resolve, reject) => { setTimeout(function() { resolve(aaa * 4) }, 1000) }) } function funcTimer2(aaa) { return new Promise((resolve, reject) => { setTimeout(function() { resolve(aaa + 1); }, 500) }) } async function func1 () { let aaa = 1; aaa = await funcTimer1(aaa); aaa = await funcTimer2(aaa); console.log(aaa); } func1 () // 5
转载请注明原文地址: https://www.6miu.com/read-5033186.html

最新回复(0)