All Products
Document Center

Mobile Platform as a Service:getcurrentpages method

Last Updated:Feb 04, 2021

Use getCurrentPages() method to obtain instances of the current page stack and return the page array stack. The first element is the homepage, the last element is the current page.

The framework maintains all the current pages in the form of stacks. The following table shows the relationship between routing switch and page stack:

Routing mode Page stack performance
Initialize Push a new page
Open a new page Push a new page
Redirect a page Pop the current page, push a new page
Return to a page Pop the current page
Switch Tab Pop all pages, only leave the new Tab page

You can use the following code snippet to detect whether the current page stack has a five-level page depth.

  1. if(getCurrentPages().length === 5) {
  2. my.redirectTo('/pages/logs/logs');
  3. } else {
  4. my.navigateTo('/pages/index/index');
  5. }
Note: Do not try to change the page stack, otherwise, it will cause routing and page status errors.