1234567891011121314151617181920212223242526272829303132333435363738 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- /*
- 同步先行 异步靠后
- 同步按照顺序调用
- */
- console.log('start')
- const fn = () => {
- return new Promise((resolve, reject) => {
- console.log(1)
- resolve(2)
- })
- }
- console.log(3)
- fn().then(res => {
- console.log(res)
- })
- console.log('end')
- </script>
- </body>
- </html>
|