wujingjing
2024-08-06 0dc8bb825b1fb47e0f477a6e4dc93638b2dedf95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// 导入封装的 网络请求模块实例
import http from '../utils/http'
 
export const reqIndexData = () => {
  // 通过并发请求获取首页的数据,提升页面的渲染速度
 
  // 通过 Promise.all 进行并发请求
  // return Promise.all([
  //   http.get('/index/findBanner'),
  //   http.get('/index/findCategory1'),
  //   http.get('/index/advertisement'),
  //   http.get('/index/findListGoods'),
  //   http.get('/index/findRecommendGoods')
  // ])
 
  // 是使用封装的 all 方法发送请求
  // 这两种方式都可以
  return http.all(
    http.get('/index/findBanner'),
    http.get('/index/findCategory1'),
    http.get('/index/advertisement'),
    http.get('/index/findListGoods'),
    http.get('/index/findRecommendGoods')
  )
}