| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 | 
							- <!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(4)
 
-     // setTimeout(()=>{
 
-     //   console.log(1)
 
-     //   setTimeout(()=>{
 
-     //     console.log(2)
 
-     //   },100)
 
-     //   setTimeout(()=>{
 
-     //     console.log(3)
 
-     //   },10)
 
-     // },0)
 
-     // console.log(5)
 
-     // let p1 = new Promise ((resolve,reject)=>{
 
-     //   reject()
 
-     //   resolve()
 
-     // }).then(()=>{
 
-     //   console.log('我成功了')
 
-     // }).catch(()=>{
 
-     //   console.log('我失败了')
 
-     // })
 
-     /* 
 
-       promise 有三种状态
 
-         pending 进行中
 
-         fullfiled 已经成功
 
-         rejected  已经失败
 
-       pending ->  fullfiled  or  pending -> rejected 
 
-       不可逆的  
 
-       1.当一个promise 被创建的时,初始状态为pending
 
-       2.当异步操作执行成功的时候,promise状态变为fullfiled 并且执行
 
-       then方法中回调函数
 
-       3.当异步操作执行失败的时候,promise状态变为rejected 并且执行
 
-       catch方法中的回调函数
 
-     */
 
-     let p1 = new Promise((resolve, reject) => {
 
-       setTimeout(()=>{
 
-         console.log(1)
 
-         reject()
 
-       },1000)
 
-       console.log(2)
 
-       resolve()
 
-     })
 
-     let p2 = new Promise ((resolve,reject)=>{
 
-       setTimeout(()=>{
 
-         console.log(3)
 
-         reject()
 
-       },800)
 
-       reject()
 
-     })
 
-     let p3 = new Promise ((resolve,reject)=>{
 
-       setTimeout(()=>{
 
-         console.log(4)
 
-         resolve()
 
-       },2000)
 
-       console.log(5)
 
-       reject()
 
-     })
 
-   
 
-     /* promise.all()将多个promise实例封装成一个promise实例 */
 
-     Promise.all([p1,p2,p3]).then(()=>{
 
-       console.log('ok')
 
-     }).catch(()=>{
 
-       console.log('error')
 
-     })
 
- /* 
 
-     Promise.race([p1,p2,p3]).then(()=>{
 
-       console.log('ok')
 
-     }).catch(()=>{
 
-       console.log('error')
 
-     }) */
 
-     // new Promise((resolve,reject)=>{
 
-     //   setTimeout(()=>{
 
-     //     console.log(1)
 
-     //     resolve()
 
-     //   },10)
 
-     // }).then(()=>{
 
-     //   console.log('ok')
 
-     // }).catch(()=>{
 
-     //   console.log('error')
 
-     // })
 
-   </script>
 
- </body>
 
- </html>
 
 
  |