1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| function a() { window.fetch("http://101.43.187.22:9501/api/nav/wallPaper").then(async response => { const resp = await response.json() console.log(resp) return resp }) console.log("a") } function b() { console.log("b") }
a() b()
|
a()
和b()
是同步执行,a()
中fetch
请求是异步操作。