WeChat applet page refresh, pull down to refresh

When I was working on a project recently, I did a little research on the page refresh mechanism of the WeChat applet.

The refresh of the WeChat applet is similar to the refresh of Ajax, and part of the page can be refreshed through setData, and the onLoad page is not required.

Of course, WeChat applet does not have a page reload method similar to that of web pages or Android.

Refreshing the page can only be done through setData or using the official pull-down refresh.

1. Use setData

this . setData ({
shop_list : new_shop_list
})


2. Use pull down to refresh

a. First set in index.json

{
//Enable pull down to refresh
  "enablePullDownRefresh" : true ,
  //Set the page color (you can see the animation effect of pull-down refresh only by setting the color)  
"backgroundTextStyle" : "dark"
}


b. Write the refresh logic code in the onPullDownRefresh method in index.js

/**
* Page-related event handlers--listen to user pull-down actions
*/
onPullDownRefresh : function () {

    //Close the refresh when the logic is executed    
    wx.stopPullDownRefresh()
},


c. Effect realization


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325518948&siteId=291194637