//1
async function f() {
return 'hello world';
}
f().then(res => console.log(res))
//2
async function f() {
return await 'hello world';
}
f().then(res => console.log(res))
写法一和写法二有啥区别
//1
async function f() {
return 'hello world';
}
f().then(res => console.log(res))
//2
async function f() {
return await 'hello world';
}
f().then(res => console.log(res))
写法一和写法二有啥区别
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
4 回答2.4k 阅读✓ 已解决
3 回答2.3k 阅读✓ 已解决
没区别,如果
await
后面的表达式不是一个Promise
,则返回该值本身