function reqyest(a,params,flag) { return new Promise(function(resolve,reject){ if(flag){ setTimeout(()=>reject('reject错误: '+a+':'+(params||'')),1000); } else { setTimeout(()=>resolve(a+': '+(params||'')),1000); } }) } reqyest('https',123456,0).then(res=>{ console.log(res) }) async function aa () { try{ let bb = await reqyest('https',123456,1); console.log(bb) }catch(err){ console.log(err) } } aa()