小程序的坑

来源:互联网 发布:惠州人民政府网络问政 编辑:程序博客网 时间:2024/06/02 03:26

问题描述:客户列表点击进入详情页,有时候有数据,有时候没有数据。


代码:

onLoad: function (options) {    // 页面初始化 options为页面跳转所带来的参数    console.log(options);    if (options.id != '' && options.id != undefined) {      this.setData({        id: options.id      })    }  },  onReady: function () {    // 页面渲染完成  },  onShow: function () {    // 页面显示    this.getCclass()    this.customerVisit()  },


原因:

this.getCclass()与函数 this.customerVisit()中都有数据请求,小程序不是同步执行,两者又有依赖关系,后面改成在this.getCclass请求成功的success条用 this.customerVisit()就没问题了



原创粉丝点击