当前位置:网站首页>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-6108: decrypt messages
- Sum of three terms (construction)
- LeetCode 0108. Convert an ordered array into a binary search tree - the median of the array is the root, and the left and right of the median are the left and right subtrees respectively
- TypeScript 基础讲解
- Operator priority, one catch, no doubt
- 背包问题 AcWing 9. 分组背包问题
- Leetcode stack related
- Usage scenarios of golang context
- [wustctf2020] plain_ WP
- Leetcode-6110: number of incremental paths in the grid graph
猜你喜欢
vsCode创建自己的代码模板
Idea debug failed
Game theory acwing 892 Steps Nim game
[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields
Game theory acwing 891 Nim games
高斯消元 AcWing 884. 高斯消元解异或线性方程组
20220213-CTF MISC-a_ good_ Idea (use of stegsolve tool) -2017_ Dating_ in_ Singapore
P2575 master fight
Design specification for mobile folding screen
NotImplementedError: Cannot convert a symbolic Tensor (yolo_boxes_0/meshgrid/Size_1:0) to a numpy ar
随机推荐
Install opencv -- CONDA to establish a virtual environment and add the kernel of this environment in jupyter
Leetcode-6109: number of people who know secrets
LeetCode 0107. Sequence traversal of binary tree II - another method
11-gorm-v2-03-basic query
Design specification for mobile folding screen
C - XOR to all (binary topic)
Leetcode-9: palindromes
Golang uses context gracefully
[moviepy] unable to find a solution for exe
Daily question 1189 Maximum number of "balloons"
JS quickly converts JSON data into URL parameters
Single chip computer engineering experience - layered idea
[learning] database: several cases of index failure
How to make water ripple effect? This wave of water ripple effect pulls full of retro feeling
中国剩余定理 AcWing 204. 表达整数的奇怪方式
栈 AcWing 3302. 表达式求值
Dataframe (1): introduction and creation of dataframe
Bash exercise 17 writing scripts to install the server side of FRP reverse proxy software
International Open Source firmware Foundation (osff) organization
MySQL advanced part 2: the use of indexes