微信小程序下拉刷新 並重新加載數據


1.在json頁面配置:

{ "enablePullDownRefresh": true }

2.調用刷新函數

 onPullDownRefresh: function() {
   wx.showNavigationBarLoading()  //在標題欄中顯示加載
 this.updateBlogs() //重新加載數據
    //模擬加載  1秒
    setTimeout(function () {
    // complete
    wx.hideNavigationBarLoading() //完成停止加載
    wx.stopPullDownRefresh() //停止下拉刷新
    }, 1000);
 },

updateBlogs: function () { var that = this wx.request({ url: common.baseUrl + 'blog_rss.php', data: { }, header: { 'Content-Type': 'application/json' }, success: function (res) { var feeds = feed.getBlogs(res.data); wx.setStorage({ key: "blog_feeds", data: feeds }) that.setData({ feeds: feeds }) } }) }
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM