|
@@ -7,8 +7,6 @@
|
|
|
</head>
|
|
|
<body>
|
|
|
<script>
|
|
|
- // async await 使用的是try{成功}catch{异常}
|
|
|
- //await会阻塞后面的方法
|
|
|
// async function fn1() {
|
|
|
// console.log(1);
|
|
|
// await fn2();
|
|
@@ -59,30 +57,27 @@
|
|
|
// async function fn1(){
|
|
|
// console.log(1)
|
|
|
// await fn2()
|
|
|
- // console.log(2) // 微1
|
|
|
- // setTimeout(()=>{ //宏1
|
|
|
+ // console.log(2)
|
|
|
+ // setTimeout(()=>{
|
|
|
// console.log(3)
|
|
|
// },1000)
|
|
|
// }
|
|
|
// async function fn2(){
|
|
|
// console.log(4)
|
|
|
// await fn3()
|
|
|
- // console.log(5) //微2
|
|
|
- // setTimeout(()=>{ //宏1
|
|
|
+ // console.log(5)
|
|
|
+ // setTimeout(()=>{
|
|
|
// console.log(31)
|
|
|
// },500)
|
|
|
// }
|
|
|
// async function fn3(){
|
|
|
// setTimeout(()=>{
|
|
|
- // console.log(6) //宏2
|
|
|
+ // console.log(6)
|
|
|
// },2000)
|
|
|
// }
|
|
|
// fn1()
|
|
|
// console.log(7)
|
|
|
|
|
|
- /***
|
|
|
- * await 后 Promise时 进入微任务
|
|
|
- * await 不是Promise 正常执行
|
|
|
// async function a1() {
|
|
|
// console.log(4)
|
|
|
// await a2();
|