javascript javascript承诺很棘手

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript javascript承诺很棘手相关的知识,希望对你有一定的参考价值。

// 1)
let promise = new Promise(
  (resolve, reject)=>{
    console.log("Promise 1");
    resolve();
  }
);

promise.then((resolve)=>{console.log("Promise 2");}, (reject)=>{console.log("reject 1");});
promise.then((resolve)=>{console.log("Promise 3")}, (reject)=>{console.log("reject 2");});
promise.then((resolve)=>{console.log("Promise 4")}, (reject)=>{console.log("reject 3");});

//2)
let promise = new Promise(
  (resolve, reject)=>{
    console.log("Promise 1");
    resolve();
  }
);

promise.then((resolve)=>{console.log("Promise 2");}, (reject)=>{console.log("reject 1");})
.then((resolve)=>{console.log("Promise 3")}, (reject)=>{console.log("reject 2");})
.then((resolve)=>{console.log("Promise 4")}, (reject)=>{console.log("reject 3");});

以上是关于javascript javascript承诺很棘手的主要内容,如果未能解决你的问题,请参考以下文章

javascript 承诺JavaScript

javascript 承诺所有运行所有承诺和处理程序错误

类函数中的 Javascript ES6 承诺

如何调试 javascript 承诺?

JavaScript - 返回承诺和/或调用回调?

JavaScript承诺 - 多个承诺失败时的逻辑