This is the 8th day of my participation in the More text Challenge. For details, see more text Challenge
-
Long data list optimization
Wechat small program official prompt page allows a maximum of 1000 labels, so if you want to make 100,000 data smoothly display, you must reduce unnecessary label nesting and try to avoid frequent use of setData, multiple setData can be combined and encapsulated into a custom component
-
Async /await resolves callback hell
Async can execute subsequent code after the code written before the function and after the await is finished
-
The life cycle
OnLaunch (), onShow(), onHide(), onError(), onPageNotFound(), onPageNotFound() OnLoad ()[page loading, called only once], onShow()[show or foreground], onReady()[render completed, called only once], onHide()[background], onUnload()[Unload] Created ()[created instance just created], Attached ()[component goes to node tree after initialization], Ready ()[Component layout in view layer completed], Moved ()[component instance moved], detached()[number of nodes off the page] Life cycle of the component: Show ()[page display], hide()[page hide], resize()[page size change]
-
The difference between bindTap and catchTap
Bindtap allows event bubbling (clicking on the current element triggers to the parent element). Catchtap prevents event bubbling
-
Routing Differences
Wx.redirectto () navigateTo(); wx.redirectto (); Switch to a page wx.switchTab() Switch to a tabBar page wx.navigateBack() Close the current page and return to the previous or multilevel page wx.relaunch() Close all pages and open a page
-
The login process
The front-end uses wX.login () to obtain the code and sends the code to the developer server using wX.request (). The back-end calls the wechat interface to obtain session_key and OpenID and returns the login status to the front-end. The front-end stores the login status and can use the login status in subsequent business interfaces
-
What apis are available for local storage
Wx. setStorage Stores data to the local environment. Synchronized version of the previous wx.setStorageSync method. Wx. getStorage Gets the content corresponding to the key GetStorageInfoSync Synchronization version of the previous method wx.clearStorage Clears the local cache synchronization version of the previous method wx.clearStorageSync
-
The method of passing data
-
Use the globalData() global variable
Define var app = getApp() on the accepted page, and use app.globalData.key to get or modify the value
-
Route transmission parameters are used
Use wX.nagivateto (), wX.redirectto () to concatenate parameters after the address to receive passed parameters in onLoad() on the receiving page
-
Using local cache
-
-
Bidirectional binding of small programs
This.setdata ({key: value}) must be used for bidirectional binding; this.data.key = value cannot be used for bidirectional binding
The article only writes part of the knowledge point, the detailed follow-up will be supplemented