Home > Article > WeChat Applet > Detailed explanation of the life cycle of the page in WeChat Mini Program Development Series (4)
This article introduces the detailed explanation of the life cycle of the WeChat mini program development series (IV) page
This series is a detailed explanation by the author from the beginning. It is suitable for beginners to watch and learn step by step according to the series;
1: Page life cycle
Add the code shown in Figure 1 to the initial page: index.js
Figure 1
After clicking "Compile", run this small program: The log is shown in Figure 2: The initial page index.js startup will start from the life cycle method call in app, js: onLaunch---onShow, and then start calling index.js The life cycle method in the page: onLoad---onShow---onReady. When "Background" is clicked, the page index.js enters the background. At this time, the life cycle method onHide is called back, as shown in Figure 3. If you click "Foreground" again ”, bringing the page back to the foreground, and then calling back the page life cycle method: onShow (note that onLoad is no longer called back at this time) as shown in Figure 4
##Figure 2 Picture 3 Picture 4itemClick: function (){ console.log("---index page itemClick---"); wx.navigateTo({ url: '../logs/logs' })Among them: wx.navigateTo represents jumping from the index.js page to the pages/logs/logs page. Note: navigateTo represents jumping to the logs page. The index page is not destroyed. Under the logs page, through the logs page The return button in the upper left corner can return to the index page. If it is wx.redirectTo, the index page is destroyed and cannot be returned from the logs page to the index page. Here we only take wx.navigateTo as an example
Figure 5
Figure 7
url: "../logs/logs?id=1&title=title abc"
})
<navigator url="../logs/logs?id=100&title=标题" >
The above is the detailed content of Detailed explanation of the life cycle of the page in WeChat Mini Program Development Series (4). For more information, please follow other related articles on the PHP Chinese website!