首页 > 微信 > 详细

小程序onShow

时间:2019-08-28 14:39:38      阅读:132      评论:0      收藏:0      [点我收藏+]
/**
 * 生命周期函数--监听页面加载
 */
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中。

小程序onShow

原文:https://www.cnblogs.com/jiqing9006/p/11423610.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!