函数异步执行 - Async/Await

4年以前  |  阅读数:486 次  |  编程语言:JavaScript 
function getSomething() {
    return "something";
}
async
function testAsync() {
    return Promise.resolve("hello async");
}
async
function test() {
    const v1 = await getSomething();
    const v2 = await testAsync();
    console.log(v1, v2); //something 和 hello async
}
test();

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8