关于then()方法的理解

then() 只有在Promise对象中才有。

  1. then()方法是异步执行。

  2. 意思是:就是当.then()前的方法执行完后再执行then()内部的程序,这样就避免了,数据没获取到等的问题。

  3. 语法:promise.then(onCompleted, onRejected);

  4. 参数

    • 必需。(promise)
      Promise 对象。

    • 必需。(onCompleted)
      承诺成功完成时要运行的履行处理程序函数。

    • 可选。(onRejected)
      承诺被拒绝时要运行的错误处理程序函数。

猜你喜欢

转载自blog.csdn.net/qq_33505829/article/details/88573715