/**
 * 生命周期函数--监听页面加载
 */
onLoad: function(options) {
    let that = this;
    const openid = app.globalData.openid || Storage.get().openid;
    initNoPage(this, [{ api: "getPerson", inData: { openid }, outDataName: "user_data" }])
}

数据只加载一次。

/**
 * 生命周期函数--监听页面显示
 */
onShow: function(options) {
    let that = this;
    const openid = app.globalData.openid || Storage.get().openid;
    initNoPage(this, [{ api: "getPerson", inData: { openid }, outDataName: "user_data" }])
}

页面每访问一次都调用一次接口。

当页面数据要求及时变化的时候,可以把接口数据放入onShow中。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
  • 2021-04-10
猜你喜欢
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
相关资源
相似解决方案