Home  >  Article  >  WeChat Applet  >  How to monitor the return button of the mini program

How to monitor the return button of the mini program

angryTom
angryTomOriginal
2020-03-13 15:11:005129browse

How to monitor the return button of the mini program

How to monitor the return button of the mini program

The system's return buttoncannot be monitored.

Change your thinking? Since you need to monitor the return key, the system does not provide an implementation. Hack it yourself

1. If you return, the original page will use the onUnload function. You can perform similar processing in this onUnload function

2. The system provides the function getCurrentPages. Based on the number of pages or pageId, the returned page is processed by itself onShow.

Let’s introduce the first implementation method:

1. In the index page, add a method to the button to jump to the details page, as shown in the figure below

How to monitor the return button of the mini program

#2. Register the onUnload event on the details page and listen for the page to be unloaded.

How to monitor the return button of the mini program

3. Click the return button at the top. Effect:

How to monitor the return button of the mini program

## Recommended learning:

小program development

The above is the detailed content of How to monitor the return button of the mini program. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn