是什么? https://www.promisejs.org/ What is a promise? The core idea behind promises is that a promise represents the result of an asynchronous operation. A promise is in one of three different states: pending - The initial state of a promise. fulfilled…
1. 定义:Promise是抽象异步处理对象以及对其进行各种操作的组件,它把异步处理对象和异步处理规则采用统一的接口进行规范化. 2. ES6 Promises 标准中定义的API: a) Constructor:采用new来实例化, var promise = new Promise(function(resolve, reject) {…}); b) Instance Method:使用then方法设置成功(resolve)和失败(reject)时的回调函数, promi…