<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
async function f(){
return 'abc';
}
console.log(f()); //返回一个promise对象
console.log(f().then((value) =>{
console.log(value);
}));
async function n(){
console.log("hahahaha");
await("caca");//会阻塞线程
console.log("hehehehe");
}
n();
console.log("caca");
</script>
</body>
</html>
async和await
最新推荐文章于 2024-09-01 10:38:50 发布