当前位置:网站首页>The route of wechat applet jumps again without triggering onload
The route of wechat applet jumps again without triggering onload
2022-07-05 06:26:00 【Heerey525】
situation :
1、 from index
Page Jump (wx.navigateTo
) To add
page , The first time will enter add
page onLoad
, But the second time from index
Page Jump (wx.navigateTo
) To add
page , Will not enter add
Page onLoad
;
2、 from add
Page Jump (wx.redirectTo
) To index
page , Will not enter the index
page onLoad
reason :
When you first enter a page , Will enter the page onLoad
, But jump around , In fact, the route is not destroyed , The page already has a routing stack , So it's cached , Will not enter again onLoad
resolvent :
1、 stay onShow
Enter to get the routing parameters
onShow: function () {
// Get the page stack of the current applet
let pages = getCurrentPages();
// The page with the largest index in the array -- Current page
let currentPage = pages[pages.length-1];
// Print out... In the current page options
console.log(currentPage.options)
}
2、switchTab
Of success
Add in callback onLoad
Method
wx.switchTab({
url: '../index/index',
success: function(e) {
var page = getCurrentPages().pop();
if (page == undefined || page == null) return;
page.onLoad();
}
})
Reference material :
Applet framework / Logic layer / Page routing
Applet usage wx.navigateTo Jump to the page , On the page onload Don't execute ?
Wechat applet switchTab New page after jump onload Problems that don't trigger
边栏推荐
- 【LeetCode】Day94-重塑矩阵
- What is socket? Basic introduction to socket
- ollvm编译出现的问题纪录
- Niu Mei's math problems
- Suppose a bank's ATM machine, which allows users to deposit and withdraw money. Now there is 200 yuan in an account, and both user a and user B have the right to deposit and withdraw money from this a
- Gaussian elimination acwing 884 Gauss elimination for solving XOR linear equations
- Install opencv -- CONDA to establish a virtual environment and add the kernel of this environment in jupyter
- 2022/6/29-日报
- Winter vacation water test 1 Summary
- MQClientException: No route info of this topic: type_ topic
猜你喜欢
高斯消元 AcWing 884. 高斯消元解异或線性方程組
3.Oracle-控制文件的管理
Find the combination number acwing 889 01 sequence meeting conditions
什么是套接字?Socket基本介绍
Leetcode-6111: spiral matrix IV
5.Oracle-錶空間
阿里巴巴成立企业数智服务公司“瓴羊”,聚焦企业数字化增长
区间问题 AcWing 906. 区间分组
There are three kinds of SQL connections: internal connection, external connection and cross connection
2021apmcm post game Summary - edge detection
随机推荐
Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022
Leetcode backtracking method
博弈论 AcWing 892. 台阶-Nim游戏
阿里新成员「瓴羊」正式亮相,由阿里副总裁朋新宇带队,集结多个核心部门技术团队
Sum of three terms (construction)
MySQL advanced part 2: MySQL architecture
Bash exercise 17 writing scripts to install the server side of FRP reverse proxy software
博弈论 AcWing 893. 集合-Nim游戏
Leetcode-6109: number of people who know secrets
Presentation of attribute value of an item
Niu Mei's math problems
Knapsack problem acwing 9 Group knapsack problem
Redis-01.初识Redis
2022-5-第四周日报
Regulations for network security events of vocational group in 2022 Guizhou Vocational College skill competition
H5内嵌App适配暗黑模式
[leetcode] day94 reshape matrix
FFmpeg build下载(包含old version)
AE tutorial - path growth animation
Series of how MySQL works (VIII) 14 figures explain the atomicity of MySQL transactions and the principle of undo logging