关注公众号:青山有路

es6 中的promise异步处理

异步处理返回结果传入到then()里面。用起来非常非常的方便

最近开发小程序中曾用到过,确实挺方便的,例如

getpoints : function (){

return   new Promise(function(resolve, reject) { if (/* 异步操作成功 */){ resolve(value); } else { reject(error); } });

}

getpoints().then(这里面会接收到上一个函数所返回的值 然后在继续操作).then(这里面会接收到上一个函数所返回的值 然后在继续操作).then().then()

以此类推,


版权所有丨如未注明 , 均为原创 , 转载请注明es6 中的promise异步处理
喜欢 (0)

Warning: Use of undefined constant PRC - assumed 'PRC' (this will throw an Error in a future version of PHP) in /www/wwwroot/gaowenjie.cc/wp-content/themes/Git-alpha/comments.php on line 17
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到