Train_2:promise简例
来源:互联网 发布:matlab软件做量化投资 编辑:程序博客网 时间:2024/05/15 23:55
<body> <script type="text/javascript"> function eat() { return new Promise(function(next, fail) { setTimeout(function() { alert('吃完饭了') ; next() ; }, 3000); }) ; } function rest() { return new Promise(function(next, fail) { setTimeout(function() { alert('休息好了') ; // next() ; fail('突然想喝点可乐了') ; }, 3000) ; }) ; } function run() { return new Promise(function(next, fail) { setTimeout(function() { alert('跑完步了') ; next(); }, 3000); }) ; } eat().then(function() { return rest(); }).then(function() { return run(); }).then(function() { alert('今天一天结束了'); }).catch(function(err) { alert(err); }); </script></body>
阅读全文
0 0
- Train_2:promise简例
- promise
- Promise
- Promise
- Promise
- Promise
- Promise
- Promise
- promise
- promise
- promise
- promise
- Promise
- Promise
- promise
- promise
- Promise
- promise
- Java知识点
- 文章标题
- 统计学学习笔记——(10)t检验
- HTTP基本认证(Basic Authentication)的java调用示例
- 算法训练 A+B problem
- Train_2:promise简例
- 性能测试jvm进程意外退出问题排查
- package.json说明 npmjs
- 架构和设计有什么区别?
- 成功抓取豆瓣读书的所有书籍
- Shadowsock Client连接到最快的服务器
- SpringMVC 使用ContentNegotiatingViewResolver整合多种视图解析器
- 回声消除概述
- 一个好用的 poi封装类