12345678910111213141516171819202122232425262728293031323334353637 |
- <!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>
- /* finally 不管promise对象最后的状态如何 都会执行 */
- /* finally 方法不接受任何参数 */
- Promise.resolve('2')
- .finally(() => {
- console.log('finnnnnn')
- })
- .then(res => {
- console.log('finally2后面的then函数', res)
- })
- Promise.resolve('1')
- .then(res => {
- console.log(res)
- })
- .finally(() => {
- console.log('finally')
- })
- </script>
- </body>
- </html>
|