异步处理返回结果传入到then()里面。用起来非常非常的方便
最近开发小程序中曾用到过,确实挺方便的,例如
getpoints : function (){
return new Promise(function(resolve, reject) { if (/* 异步操作成功 */){ resolve(value); } else { reject(error); } });
}
getpoints().then(这里面会接收到上一个函数所返回的值 然后在继续操作).then(这里面会接收到上一个函数所返回的值 然后在继续操作).then().then()
以此类推,