ES6中的promise

 promise是异步编程的解决方案,它的写法比jquery里面的$.ajax()要好,没有嵌套,例子:

    let f=()=>{

       return new Promise((res,rej)=>{

                   res();

 })

 }

  let 0=f();

 o.then.then.then 

 o.then.then.then 相当于o.sucess().sucess().sucess()

 这种写法比较优雅

 

posted @ 2017-12-19 18:54  Angel爽  阅读(268)  评论(0编辑  收藏  举报