Abstract: In the development process of WeChat applet, we will definitely encounter the need to jump between pages, so how to monitor the events between page jumps? In our previous article: Research on eLong WeChat Mini Program Framework Components (with source code) as an example, let’s take a look at the events when the mini program jumps between pages...
In the development process of WeChat applet, we will definitely encounter the need to jump between pages. So how to monitor the events between page jumps? We took a previous article: Research on Framework Components of Yilong WeChat Mini Program (source code attached) as an example to take a look at the event mechanism when mini programs jump between pages. We know that the mini program provides four mechanisms to change the view, including opening a new page, page redirection, page return, and tabBar switching. It hosts the page. life cycle, and provides corresponding life cycle events for the application to facilitate business processing at each stage of the application, but there is no corresponding event mechanism for jumping between pages, for example -
The above two scenarios are very common and boil down to page How to interact conveniently? Of course, we can achieve the goal by passing parameters or global data objects through page jumps, but there are some restrictions on use (converting parameters or maintaining global objects)! So the event mechanism is used to solve this problem in the elong applet project . We rewrote navigateToAPI. After page A calls this interface to jump to the page, the method returns an event object event to page A. This object can register custom events, and the target page (page B) can follow the business The demand triggers the event response, and the relevant data is passed as a parameter to the listening callback. ##BPage
##API
##Event ##Part of the code is as follows:
|
The above is the detailed content of How to monitor events when jumping between WeChat applet pages. For more information, please follow other related articles on the PHP Chinese website!