当前位置:网站首页>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
边栏推荐
- 1099 建立二叉搜索树 (30 分)
- Chris LATTNER, father of llvm: the golden age of compilers
- Noyer électronique stm32 Introduction à l'Internet des objets 30 étapes notes I. différences entre la Bibliothèque Hal et la Bibliothèque standard
- Get the absolute path of the class according to the bytecode
- The K neighbors of each sample are obtained by packet switching
- After a circle, I sorted out this set of interview questions..
- Notes on 30 steps of introduction to the Internet of things of yangtao electronics STM32 III. cubemx graphical programming and setting the IO port on the development board
- 完全二叉搜索树 (30 分)
- GUI编程简介 swing
- Yangtao electronic STM32 Internet of things introduction 30 steps notes 1. The difference between Hal library and standard library
猜你喜欢
Enterprise wechat application authorization / silent login
OneFlow学习笔记:从Functor到OpExprInterpreter
PLC的点表(寄存器地址和点表定义)破解探测方案--方便工业互联网数据采集
Pctp test experience sharing
valgrind和kcachegrind使用运行分析
L2-022 重排链表 (25 分)(map+结构体模拟)
Test your machine learning pipeline
Latex paper typesetting operation
STM32使用HAL库,整体结构和函数原理介绍
1099 建立二叉搜索树 (30 分)
随机推荐
Bk3633 specification
Please arrange star trek in advance to break through the new playing method of chain tour, and the market heat continues to rise
Wechat: get the owner of a single tag
数字政府建设中政务中台中的技术创新点
Brief steps to build a website / application using flash and H5
STM32 uses Hal library. The overall structure and function principle are introduced
洋桃电子STM32物联网入门30步笔记三、新建CubeIDE工程和设置讲解
Introduction to matlab
Failed to prepare device for development
After a circle, I sorted out this set of interview questions..
Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
Withholding agent
【精品】利用动态代理实现事务统一管理 二
微信:获取单个标签所有人
汇编语言与逆向工程 栈溢出漏洞逆向分析实验报告
Correct method of calculating inference time of neural network
GUI编程简介 swing
Whether the same binary search tree (25 points)
PCTP考试经验分享
Judgment on heap (25 points) two insertion methods