Micro letter applet - Life Cycle

Applet lifecycle

Official Documents

What is performed in the app life cycle?

Execution App () function is a registered App

1 at the time of registration app, you can enter the scene to determine the applet

2 We can perform the function through the life cycle, do some data request

3 You can set a global object in the app, so that all the pages can be used

Page ({
   / ** 
   * initial page of data
    * / 
  Data: { 
  },
   / ** 
   * lifecycle function - monitor the page is loaded
    * / 
  the onLoad: function (Options) { 
    the console.log ( " the onload " ) 
  },

   / ** 
 * life cycle function - monitor page displays
  * / 
  onShow: function () { 
    console.log ( " OnShow " ) 
  },
   / ** 
   * life cycle function - listen for the first time the page rendering is complete
    * / 
  the onReady: function () { 
    the console.log ( " the onReady " ) 
  },
   / **
   * Life Cycle function - listen for the hidden page
    * / 
  onHide: function () { 
    console.log ( " onHide " ) 
  },
   / ** 
   * Life Cycle function - listen to uninstall the page
    * / 
  onUnload: function () { 
    console.log ( " the onUnload " ) 
  },
   // monitor user pull-down action, 
  onPullDownRefresh: function () {
     // If we want to this, must be " enablePullDownRefresh " : to true 
    the console.log ( " drop-down under the brush " ) 
  },
   // page event handler pulling the bottom 
  onReachBottom: function () { 
    the console.log (" Pulled on the bottom " ) 
},
 // page scrolling triggering event handler 
onPageScroll: function (E) { 
  the console.log ( " rollers understand " , E) 
} 

})
test.js

 

A network request function in the life cycle, the data acquired from the server

2 initialize some data, in which data, in order to facilitate reference wxml

3 monitor wxml events are bound to corresponding event function

There are 4 page scroll, pull-up, pull-down, etc.

Note: excerpt from small ape learn

 

 

Guess you like

Origin www.cnblogs.com/waller/p/11794193.html