美文网首页
【vue】reduce里面使用async await

【vue】reduce里面使用async await

作者: xxxsjan | 来源:发表于2021-04-23 08:35 被阅读0次

reduce里面使用async await

async create(){
  let arr = [xxx]
  let topData = await arr.reduce(async (pre, cur) => {
          let { data } = await this.$axios({xxx});
          return [...(await pre), data];
   },[])
}

由于上一个是promise,
需要await 处理上一个(pre),
不然输出都是就是一组Promise,而不是一组数据

相关文章

网友评论

      本文标题:【vue】reduce里面使用async await

      本文链接:https://www.haomeiwen.com/subject/scoqrltx.html