当前位置:网站首页>Applet in wechat and app get current ()
Applet in wechat and app get current ()
2022-04-23 08:52:00 【Little, little, cute】
getCurrentPages() Function to get an instance of the current page stack , Given as an array in the order of stacks , The first element is the home page , The last element is the current page .
Be careful : getCurrentPages() It is only used to show the page stack , Do not modify the page stack , So as not to cause page status errors .
uniapp Official documents :https://uniapp.dcloud.io/api/window/window.html#getcurrentpages
Applet official documentation :https://developers.weixin.qq.com/miniprogram/dev/reference/api/getCurrentPages.html
The specific method is described in detail in the official document Here are only the examples used
1. Judge whether the current page enters app Or the first page of the applet , A typical scenario is the sharing page of an applet , The details page shared to users cannot be returned to the home page , Instead, exit the applet directly
const pages = getCurrentPages();
if(pages.length == 1){
console.log(" The current page is to enter the applet /app The first page of , Logical processing can be done here ")
}
2. Cross page assignment You can modify the value of the previous page on the current page
let pages = getCurrentPages();// The current page stack
if(pages.length>0){
let prevPage = pages[pages.length - 2];// Previous page
prevPage.setData({
// Assign a value directly to the previous page
});
}
3. When I jump to the page , Refresh the existing page , for instance , When switching between multiple languages, refresh the applet or app To update the language text, you need this
uni.switchTab({
url: '/pages/tab/home',
success: function (e) {
var page = getCurrentPages().pop(); // Current page
if (page == undefined || page == null) return;
page.onLoad(); // Page exists, refresh the current page Or other operations
}
})
4. Get information about the current page
let pages = getCurrentPages(); // The current page stack
// The current page is the last element of the page stack
let prevPage = pages[pages.length - 1];// Current page
// pop() Method is used to delete and return the last element of the array Or use this method to get the current page
// let prevPage = pages.pop();// Current page
console.log( prevPage.route) // Print the path information of the current page : Output is ‘pages/tab/home’
版权声明
本文为[Little, little, cute]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230817366622.html
边栏推荐
- K210 learning notes (II) serial communication between k210 and stm32
- Pctp test experience sharing
- Solidity 问题汇总
- Stm32f103zet6 [development of standard library functions] - Introduction to library functions
- 论文阅读《Multi-View Depth Estimation by Fusing Single-View Depth Probability with Multi-View Geometry》
- OneFlow學習筆記:從Functor到OpExprInterpreter
- Go语言自学系列 | golang结构体指针
- php基于哈希算法出现的强弱比较漏洞
- Consensus Token:web3. 0 super entrance of ecological flow
- L2-3 romantic silhouette (25 points)
猜你喜欢

STM32使用HAL库,整体结构和函数原理介绍

Solidity 问题汇总

Valgrind et kcachegrind utilisent l'analyse d'exécution

Virtual online exhibition - Online VR exhibition hall realizes 24h immersive exhibition viewing

L2-024 部落 (25 分)(并查集)

Notes on 30 steps of introduction to Internet of things of yangtao electronics STM32 III. Explanation of new cubeide project and setting

L2-3 romantic silhouette (25 points)

洋桃电子STM32物联网入门30步笔记二、CubeIDE下载、安装、汉化、设置

RCC introduction of Hal Library

cadence的工艺角仿真、蒙特卡洛仿真、PSRR
随机推荐
Basic usage of synchronized locks
Taxable income
Flink同时读取mysql与pgsql程序会卡住且没有日志
Brief steps to build a website / application using flash and H5
L2-022 重排链表 (25 分)(map+结构体模拟)
Technological innovation in government affairs in the construction of Digital Government
洋桃电子STM32物联网入门30步笔记四、工程编译和下载
Please arrange star trek in advance to break through the new playing method of chain tour, and the market heat continues to rise
2022-04-22 openebs cloud native storage
PLC point table (register address and point table definition) cracking detection scheme -- convenient for industrial Internet data acquisition
Illegal character in scheme name at index 0:
Wechat: get the owner of a single tag
Reference passing 1
dataBinding中使用include
K210 learning notes (II) serial communication between k210 and stm32
Idea package jar file
Find the sum of simple types of matrices
Consensus Token:web3. 0 super entrance of ecological flow
xctf刷题小记
洋桃电子STM32物联网入门30步笔记三、新建CubeIDE工程和设置讲解