实现:fn(),f2()方法都执行完之后 ,打印出 ‘完成’
<script>
function fn(time){
return new Promise((resolve,reject)=>{
setTimeout(function(){
resolve('这是值1');
console.log('3s');
},time);
})
}
function fn2(time){
return new Promise((resolve,reject)=>{
setTimeout(function(){
resolve('这是值2');
console.log('2s');
},time);
})
}
async function start(){
await Promise.all([fn(3000),fn2(2000)]).then(res=>{console.log(res)});
console.log('完成');
}
start();
</script>