当前位置:网站首页>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
边栏推荐
- 阿里巴巴成立企业数智服务公司“瓴羊”,聚焦企业数字化增长
- 求组合数 AcWing 888. 求组合数 IV
- Basic explanation of typescript
- Interval problem acwing 906 Interval grouping
- Leetcode divide and conquer / dichotomy
- Design specification for mobile folding screen
- Modnet matting model reproduction
- Winter vacation water test 1 Summary
- Dataframe (1): introduction and creation of dataframe
- [BMZCTF-pwn] ectf-2014 seddit
猜你喜欢
Game theory acwing 891 Nim games
Client use of Argo CD installation
How to make water ripple effect? This wave of water ripple effect pulls full of retro feeling
中国剩余定理 AcWing 204. 表达整数的奇怪方式
Interval problem acwing 906 Interval grouping
Quickly use Amazon memorydb and build your own redis memory database
MySQL怎么运行的系列(八)14张图说明白MySQL事务原子性和undo日志原理
Gauss Cancellation acwing 884. Solution d'un système d'équations Xor linéaires par élimination gaussienne
MySQL advanced part 1: stored procedures and functions
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
随机推荐
7.Oracle-表结构
2.Oracle-数据文件的添加及管理
FFmpeg build下载(包含old version)
How to set the drop-down arrow in the spinner- How to set dropdown arrow in spinner?
1.手动创建Oracle数据库
2022-5-第四周日报
求组合数 AcWing 889. 满足条件的01序列
Leetcode-22: bracket generation
Redis-02.Redis命令
Currently clicked button and current mouse coordinates in QT judgment interface
Idea debug failed
Paper reading report
Alibaba's new member "Lingyang" officially appeared, led by Peng Xinyu, Alibaba's vice president, and assembled a number of core department technical teams
【LeetCode】Day95-有效的数独&矩阵置零
Bit of MySQL_ OR、BIT_ Count function
Modnet matting model reproduction
4. Object mapping Mapster
__ builtin_ Popcount() counts the number of 1s, which are commonly used in bit operations
Quickly use Amazon memorydb and build your own redis memory database
Winter vacation water test 1 Summary