123456789101112131415161718192021222324252627282930313233343536373839404142 |
- async function main(){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- let res1 = await waitSeconds(500,()=>{console.log(1)})
- console.log(res1)
- let res2 = await waitSeconds(200,()=>{console.log(2)})
- console.log(res2)
- let res3 = await waitSeconds(100,()=>{console.log(3)})
- console.log(res3)
- let res4 = await waitSeconds(1000,()=>{console.log(4)})
- console.log(res4)
- }
- function waitSeconds(duration,handle) {
- return new Promise((resolve, reject) => {
- setTimeout(() => {
- handle()
- resolve(`等待了${duration}ms`);
- }, duration);
- });
- }
- main()
|