如何实现多个异步同步执行?

var p1 = new Promise(function(resolve,reject){
setTimeout(function(){
console.log('1');
resolve()
},3000)
})
function p2(){
return new Promise(function(resolve,reject){
setTimeout(function(){
console.log("2");
resolve();
},2000)
})
}
function p3(){
return new Promise(function(resolve,reject){
setTimeout(function(){
console.log("3");
resolve();
},1000)
})
}
function p4(){
return new Promise(function(resolve,reject){
setTimeout(function(){
console.log("4");
resolve();
},500)
})
}
p1.then(function(){
return p2()
})
.then(function(){
return p3();
})
.then(function(){
return p4();
})
原文地址:https://www.cnblogs.com/Guernicas/p/9834751.html