使用场景:多个请求方法拿到数据之后需要对这不同的数据进行比较,之后在输出并渲染

思路:使用promise.all()异步操作:

Promise.all([
             //上架
             new Promise((resolve,reject)=>{
                 this.axios(config.API + '/api/aply/statistics/hit_the_shelf',{},params).then((res)=>{
                   console.log(res)
                   resolve(res)
                })
             }),
             //上架环比
             new Promise((resolve,reject)=>{
                this.axios(config.API + '/api/aply/statistics/hit_the_shelf',{},params1).then((res)=>{
                   conso.log(res1)
                   resolve(res1)
               })
          }),
     ]).then(res=> {
        console.log(res)                   //是一个数组,里边的res[index]值就是两个不同的请求返回的结果
})

 

相关文章:

  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2022-02-17
猜你喜欢
  • 2022-12-23
  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案