In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the life cycle function of WeChat Mini Programs". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what is the life cycle function of WeChat Mini Programs"?
Since Mini Program's data was not released when we exited Mini Program, the data still did not become initialized when we clicked on it again.
Solution: declare a variable isClose in Mini Program data data, which defaults to true to determine whether it is opened from the entry. When you click to jump to the page or close Mini Program, it will trigger the OnHide function. In this function, when you judge isClose is true, you will open it after closing. When you jump to the page, set isClose to false first, so that when you trigger the OnHide function, isClose is flase will not execute and enter the page that you jump to. Then the OnUnload function of the page that returns from the page that triggers the jump sets a timer in this function to change isClose to true after 200ms, so that when Mini Program is closed and re-entered, isColse is still true when it is judged to enter the page for the first time.
WeChat Mini Programs's Life cycle function
1.1 listening page loading
OnLoad: function (options) {}
A page is called only once, and you can get the query parameters that are called to open the current page in onLoad.
1.2 the first rendering of the listening page is complete
OnReady: function () {}
A page is called only once, indicating that the page is ready to interact with the view layer.
1.3 Monitoring page display
OnShow: function () {}
It is called every time the page is opened.
1.3 listening pages hidden
OnHide: function () {}
Called when navigateTo or the bottom tab is switched.
1.4 uninstall the listening page
OnUnload: function () {}
Called when redirectTo or navigateBack.
Functions unique to WeChat Mini Programs's app.js
2.1 listening for Mini Program initialization
OnLaunch:function () {}
OnLaunch will be triggered when Mini Program initialization is completed (only once globally)
2.2 error listener function
OnError:function () {}
When a script error occurs on Mini Program, or when the api call fails, onError will be triggered with an error message.
At this point, I believe you have a deeper understanding of "what is the life cycle function of WeChat Mini Programs". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.