app.json设置窗口样式:

Small program mall front end:Carousel map and recommendation data request

Small program mall front end:Carousel map and recommendation data request

由于我们不需要每个页面都下拉刷新,以及点击tabBar都是显示小程序这个样本,所以其他属性去掉:

Small program mall front end:Carousel map and recommendation data request

Small program mall front end:Carousel map and recommendation data request

轮播图:

请求轮播图相关数据:对于首页轮播图以及其他首页数据相对来说比较少,所以使用一个请求来处理这些数据即可。

导出一个函数:

Small program mall front end:Carousel map and recommendation data request

封装网络请求:

Small program mall front end:Carousel map and recommendation data request

首先去首页home.js文件去发送网络请求:

页面创建完成之后就发送网络请求:

Small program mall front end:Carousel map and recommendation data request

可以对该函数进行下封装:

讲网络请求封装成三层:根据具体业务去抽取url的前缀:(config.js)

Small program mall front end:Carousel map and recommendation data request

首先我们创建在网络请求层中去创建一个home.js文件:

封装一个函数:

Small program mall front end:Carousel map and recommendation data request4

导入函数:

Small program mall front end:Carousel map and recommendation data request

Small program mall front end:Carousel map and recommendation data request

Small program mall front end:Carousel map and recommendation data request

此时就完成了数据的请求。

 

 

 

 

 

相关文章:

  • 2021-08-10
  • 2022-01-01
  • 2021-06-26
  • 2022-03-03
  • 2021-12-08
  • 2021-11-27
  • 2021-06-10
猜你喜欢
  • 2021-09-13
  • 2021-09-08
  • 2021-12-22
  • 2021-09-28
  • 2022-02-22
  • 2021-05-26
相关资源
相似解决方案