let arr = [] function sendPost(text){ return new Promise((resolve)=>{ setTimeout(()=>{ arr.push({text,time:new Date()}) resolve(text) },1000) }) } const text1=['a1','a2','a3','a4'] const text2=['b1','b2','b3','b4']
想要的结果如下,是一次性输出text1再每隔一秒顺序输出text2(时间格式我简略了,这不是重点),用promise的话怎么实现
arr=[ {text: "a1", time: 11:44:51},{text: "a2", time: 11:44:51},{text: "a3", time: 11:44:51},{text:"a4", time: 11:44:51},{text: "b1", time: 11:44:52},{text: "b2", time: 11:44:53},{text: "b3", time:11:44:54},{text: "b4", time: 11:44:55}]
holdtom
拉莫斯之舞
相关分类