1、封装接口函数,并使用module.exports导出
2、在需要使用的界面使用require导入方法接口函数文件,传入所需接口后缀
3、大多数情况下需要使用wx:for进行遍历,如wx:for="{{list}}" wx:key="{{index}}" wx:for-item=‘index’
4、渲染数据,如{{list[index].headimg}}可完成
5、跳转页面时需要用到商品或信息id时,在跳转函数中使用
var id = e.currentTarget.dataset.id
// console.log(id)
wx.navigateTo({
url: ‘…/detail/detail?id=’+id,
})
将id赋值给跳转的页面
6、跳转后的页面需要在onload方法里将传过来的option.id传给当前页面的id,根据id可找到所需的数据
微信小程序获取后端数据
最新推荐文章于 2023-10-24 08:00:00 发布