1 <script>
2 new Promise(function (resolve,reject) {
3 setTimeout(function () {
4 console.log('First');
5 resolve();
6 },1000);
7 }).then(function () {
8 return new Promise(function (resolve,reject) {
9 setTimeout(function () {
10 console.log("Second");
11 resolve();
12 },4000);
13 });
14 }).then(function () {
15 setTimeout(function () {
16 console.log("Third");
17 },3000);
18 });
19 </script>
.then()方法是异步执行;当.then()前的方法执行完后再执行then()内部的程序,这样就避免了,数据没获取到等的问题