let send = (item) => Promise.resolve(`此时参数是:(${item})`)

async function init(){
    const arr = [1,2,3,4,5]
    let res = 0
    await arr.forEach(item=>{
        send(item).then(e=>{
            console.log(e)
            res++
            console.log(res)
        })
    })
    console.log(res)
}

init()

  

posted on 2019-02-21 18:09  前端入门菜鸟  阅读(291)  评论(0编辑  收藏  举报