In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Today, the editor will share with you the relevant knowledge about what the life cycle function is in WeChat Mini Programs. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
WeChat Mini Programs life cycle function
Mini Program to determine whether the current home page is returned from another page or opened by the portal.
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
These are all the contents of the article "what is the Life cycle function in WeChat Mini Programs?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
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.