jjzjj

printIn1

全部标签

javascript - 如何在不使用 then 方法的情况下定义 promise 链

我已经寻找过类似的问题,但它们与JQuery或任何其他库有关。首先,我写了这个:constprintIn1Sec=(value)=>{returnnewPromise(resolve=>{setTimeout(()=>{console.log(value);resolve();},1000)});};并以这种方式使用它:printIn1Sec(1).then(()=>printIn1Sec(2)).then(()=>printIn1Sec(3));我认为then非常重要,因为它允许我们在promise被解决后立即执行一些事情。但我一直在寻找这样的东西:printIn1Sec(1).pr