4.html 717 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <script>
  11. /* finally 不管promise对象最后的状态如何 都会执行 */
  12. /* finally 方法不接受任何参数 */
  13. Promise.resolve('2')
  14. .finally(() => {
  15. console.log('finnnnnn')
  16. })
  17. .then(res => {
  18. console.log('finally2后面的then函数', res)
  19. })
  20. Promise.resolve('1')
  21. .then(res => {
  22. console.log(res)
  23. })
  24. .finally(() => {
  25. console.log('finally')
  26. })
  27. </script>
  28. </body>
  29. </html>