小程序 刷新当前页面

小程序刷新当前界面 使用onPullDownRefresh;

官方文档地址:https://developers.weixin.qq.com/miniprogram/dev/reference/api/Page.html

 然后再页面对应的json中添加 "enablePullDownRefresh":true

否则设置onPullDownRefresh不生效

如果顶部标题是白色的需要在页面相对的json里添加 "backgroundTextStyle": "dark",

才能显示加载效果 ,效果图:

在模拟器上发现刷新成功之后 这上图的三个点会直接隐藏 在手机上却不会直接隐藏掉,所以要用wx.stopPullDownRefresh();

如果请求接口成功返回数据 添加wx.stopPullDownRefresh()即可。

 

 
原文地址:https://www.cnblogs.com/cntt/p/13398336.html