方案一
promise多个then的调用
function run1(){
console.log('run1');
return new Promise((resolve,reject)=>{
setTimeout(function(){
console.log('异步过程1');
resolve('我是数据1')
},1000)
})
}
function run2(){
console.log('run2');
return new Promise((resolve,reject)=>{
setTimeout(function(){
console.log('异步过程2');
resolve('我是数据2')
},1000)
})
}
function run3(){
console.log('run3');
return new Promise((resolve,reject)=>{
setTimeout(function(){
console.log('异步过程3');
resolve('我是数据3')
},1000)
})
}
run1().then(function(data){
console.log(data)
return run2()
}).then(function(data){
console.log(data)
return run3()
}).then(function(data){
console.log(data)
})
方案二:
new Promise(function(resolve, reject) {
se