Promise.then不执行

sun*_*ris 5 javascript promise

在以下代码块中,仅将"第一个承诺"记录到控制台.这是为什么?我试图编写一个测试来弄清楚.tatch()在.catch()之后的执行情况,但是除了第一个承诺之外什么也没有.这里发生了什么?

   function foo() {
      return new Promise((resolve, reject) => {
        return console.log('first promise')
      })
      .then(() => console.log('first then'))
      .catch(() => console.log('catch block'))
      .then(() => console.log('last block'))
      .then(() => resolve)
    }
    foo();
Run Code Online (Sandbox Code Playgroud)

小智 5

正如Yury所说,你不是在解决这个承诺,只是简单地返回一个日志.

https://jsfiddle.net/k7gL57t3/

 function foo() {
   var p1 = new Promise((resolve, reject) => {
     resolve("Test");
   })
   p1.then(() => console.log('first then'))
     .then(() => console.log('last block'))
     .then(() => resolve)
     .catch(() => console.log('catch block'));
 }
foo();
Run Code Online (Sandbox Code Playgroud)